I had saved files in folder "uploads".I want to display uploaded filename in the table. There are two files. london.jpeg & usa.pdf
Table:
no Name File
1 abc london
2 xyz usa
When one click on london or usa, one should able to see the file.
I need urngent help. I hope i am clear for everyone.
*ERROR: Unknown error type: [8] Undefined index: picture<br /> *
Here is the code:
// dashboard.php
$upload_dir = '/home/www/images/file-upload/upload/'; // Directory for file storing
$upload_dir = $upload_dir . basename($_FILES['picture']['name']);
$filename = $_FILES['picture']['name'];
$query = "INSERT INTO "
// upload-picture.php
<?php
$upload_dir = '/home/www/images/file-upload/upload/'; // Directory for file storing
$preview_url = 'http://www.sitename.com/images/file-upload/upload/'; //
$filename= '';
$result = 'ERROR';
$result_msg = '';
$allowed_image = array ('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg','image/png','image/pdf');
define('PICTURE_SIZE_ALLOWED', 2242880); // bytes
if (isset($_FILES['picture'])) // file was send from browser
{
if ($_FILES['picture']['error'] == UPLOAD_ERR_OK) // no error
{
if (in_array($_FILES['picture']['type'], $allowed_image)) {
if(filesize($_FILES['picture']['tmp_name']) <= PICTURE_SIZE_ALLOWED) // bytes
{
$filename = $_FILES['picture']['name'];
move_uploaded_file($_FILES['picture']['tmp_name'], $upload_dir.$filename); // pb ici
//phpclamav clamscan for scanning viruses
//passthru('clamscan -d /var/lib/clamav --no-summary '.$upload_dir.$filename, $virus_msg); //scan virus
$virus_msg = 'OK'; //assume clamav returing OK.
if ($virus_msg != 'OK')
{
unlink($upload_dir.$filename);
$result_msg = $filename." : ".FILE_VIRUS_AFFECTED;
$result_msg = '<font color=red>'.$result_msg.'</font>';
$filename = '';
}
else
{
// main action -- move uploaded file to $upload_dir
$result = 'OK';
}
}
else
{
$filesize = filesize($_FILES['picture']['tmp_name']);// or $_FILES['picture']['size']
$filetype = $_FILES['picture']['type'];
$result_msg = PICTURE_SIZE;
}
}
}else {
$result_msg = SELECT_IMAGE;
}
}
elseif ($_FILES['picture']['error'] == UPLOAD_ERR_INI_SIZE)
$result_msg = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
else
$result_msg = 'Unknown error';
// This is a PHP code outputing Javascript code.
echo '<script language="JavaScript" type="text/javascript">'."\n";
echo 'var parDoc = window.parent.document;';
if ($result == 'OK') {
echo 'parDoc.getElementById("picture_error").innerHTML = "";';
}
else {
echo "parDoc.getElementById('picture_error').innerHTML = '".$result_msg."';";
}
if($filename != '') {
echo "parDoc.getElementById('img_prev').innerHTML = '<img src=\'$preview_url$filename\' id=\'preview_picture_tag\' name=\'preview_picture_tag\' />';";
}
echo "\n".'</script>';
exit(); // do not go futher
echo "enter";
?>