I'm having trouble debugging why the processing of my file upload is not working. I've created a HTML5 file uploader on my page which calls my upload.php.
upload.php
// File should be saved in same folder as upload.php
$uploaddir = '/';
$uploadfile = $uploaddir . basename($_FILES['fileToUpload']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.
";
} else {
echo "Possible file upload attack!
";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
The result of my debug shows me the following:
move_uploaded_file appears to return false and thus not being able to move the uploaded file from temp location to my specified location.
I've made sure to set the permissions on the folder where my upload.php resides and where the file should be save to 777.
Question Is there any way to get more information about why the file was not saved to help me understand what i did wrong ?
// File should be saved in same folder as upload.php
$uploaddir = '/';
/something
is an absolute path; $uploaddir points to the root of your file system (that's not the same as the document_root of the webserver). The webserver process most likely doesn't have write permissions there.
Take a look at the __DIR__ "constant" at http://php.net/language.constants.predefined