I have a very basic upload script, probably lifted straight off the php.net/move_upload_files function page.
move_uploaded_file()
is failed because it canno
It may also be that you destination folder does not exists or you don't have write permission.
Simple test to do right before the move_uploaded_file() function:
if (!file_exists("upload")) {
if (mkdir("upload")) {
echo "Upload directory created!";
}
else {
die( "Invalid upload directory!" );
}
}
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
The file is removed after the script finishes executing. If you run your script, and then check the /tmp/ folder, the file will not be there no matter what.
You are using the return value of move_uploaded_file()
the wrong way round:
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_file))
{
$result['error'] = 'true';
}
else
{
$result['error'] = 'false';
$result['file_loc'] = $upload_file;
}
For future reference this can also happen when Apache does not have access to the destination directory (Remember to change the ACLs !!).
I've had this problem myself. In my case php was uploading to the wrong tmp folder. Instead of using the domains tmp folder (in a virtual host on plesk) it was uploading straight to the OS temporary folder.
Check the settings of your temporary folders