Things I have checked:
- upload_max_filesize
- file_uploads = On
- directory's permissions are 777
- checking the file actually uploads
Here's my html form:
<form action="upload.php" method="post" enctype="multipart/form-data">
Select a file to upload:
<br>
<input type="file" name="uploadFile" id="uploadFile">
<br>
<input type="submit" value="Upload Image" name="submit">
</form>
Here's a simplified of upload.php:
<?php
if ($_FILES['uploadFile']['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $_FILES['file']['error']);
}
else {
echo "Upload successful.<br>";
}
if (move_uploaded_file($_FILES["uploadFile"]["tmp_name"], "var/www/html/pictures/" . basename($_FILES["uploadFile"]["name"]))) {
echo "The file ". basename( $_FILES["uploadFile"]["name"]). " has been uploaded.<br>";
}
else {
echo "Error: ", PHP_EOL;
print_r(error_get_last());
exit;
}
?>
And here's the output I get:
Upload successful. Error: Array ( [type] => 2 [message] => move_uploaded_file(): Unable to move '/tmp/phpDelzbW' to 'var/www/html/pictures/archer.jpg' [file] => /var/www/html/upload.php [line] => 13 )