hello everyone…i am new for this script, hope u guys able to help me. Thank you in advance! :-*
im using xampp for localhost, all .php file i place it in xampp\htdocs ( i create a uploads folder outside the htdocs, c:\xampp\uploads)
This is the error message i get after i upload the file:
Notice: Undefined variable: FILES in C:\xampp\htdocs\upload_file.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in C:\xampp\htdocs\upload_file.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\xampp\tmp\phpAE.tmp’ to ‘…/uploads/’ in C:\xampp\htdocs\upload_file.php on line 15
Your file could not be uploaded because: Something unforeseen happened…
following is my upload_file.php script , i highlighted on line 15:
Upload a File <?php ///Script - 11.4 - upload_file.php /* This script displays and handles an HTML form. this script takes a file upload and stored it on the servers */if(isset($_POST[‘submitted’])) { //Handle the form
//Try to move the upload file:
if (move_uploaded_file ($_FILES[‘thefile’][‘tmp_name’],"…/uploads/{$FILES[‘thefile’][‘name’]}")){
print '<p>Your file has been uploaded.</p>';
}else { //problem!!
print '<p style="color:red;">Your file could not be uploaded because: ';
///print a message based upon the error:
switch ($_FILES[‘thefile’][‘error’]) {
case 1:
print ‘The file exceeds the upload_max_filesize setting in php.ini’;
break;
case 2:
print ‘The file exceeds the MAX_FILE_SIZE setting in the HTML form’;
break;
case 3:
print ‘The file was only partially uploaded’;
break;
case 4:
print ‘No file was uploaded’;
break;
case 6:
print ‘The temporary folder does not exist.’;
break;
default:
print ‘Something unforeseen happened.’;
break;
}
print ‘.
’; /////complete the paragraph.} // End of move_uploaded_file()IF
} // End of submission IF
//Leave PHP and display the form:
?>
Upload a file using this form: