I have following html form:
<form enctype="multipart/form-data" method="post" action="image_upload_script.php?u=<?php echo $u; ?>">
<div id="dropzone">
<div>Drop Files Here Or Click To Browse</div>
<input name="upload" id="upload" class="button" type="file" />
</div>
<input type="submit" id="uplbtn" value="Upload"/>
</form>
and this is the relevant php section:
$fileName = $_FILES["upload"]["name"];
$u = $_GET['u'];
$fileTmpLoc = $_FILES["upload"]["tmp_name"];
$fileType = $_FILES["upload"]["type"];
$fileSize = $_FILES["upload"]["size"];
$fileErrorMsg = $_FILES["upload"]["error"];
$kaboom = explode(".", $fileName);
$fileExt = end($kaboom);
print_r($_FILES);
if (!$fileTmpLoc) {
echo "ERROR: Please browse for a file before clicking the upload button.";
exit();
} else if($fileSize > 5242880) {
echo "ERROR: Your file was larger than 5 Megabytes in size.";
unlink($fileTmpLoc);
exit();
} else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) {
echo "ERROR: Your image was not .gif, .jpg, or .png.";
unlink($fileTmpLoc);
exit();
} else if ($fileErrorMsg == 1) {
echo "ERROR: An error occured while processing the file. Try again.";
exit();
}
$moveResult = move_uploaded_file($fileTmpLoc, "/var/www/domain.com/public_html/static_domain/upload/Images/$fileName");
if ($moveResult != true) {
$error = error_get_last();
echo "ERROR: $error[message]";
unlink($fileTmpLoc);
exit();
}
This delivers the following feedback from the php:
Array ( [upload] => Array ( [name] => 1961 Impala factory photo 3a.jpg [type] => image/jpeg [tmp_name] => /tmp/phpSOhr6N [error] => 0 [size] => 46396 ) ) ERROR: move_uploaded_file(): Unable to move '/tmp/phpSOhr6N' to '/var/www/domain.com/public_html/static_domain/upload/Images/1961 Impala factory photo 3a.jpg'
It just doesn't move it to the tmp - I tested this by commenting out the unlink in the php to see if it still would sit there if I checked, but no such luck :( All the involved folders have 0777 permission and www-data is the owner of each one of them and tmp is also fully free at 1777. It displays this behavior as well when the form file and the php file are living in the same folder on my https-static domain as well as in a subdomain without https (for now). What am I doing wrong here? Is there something I forgot? Your help would be greatly appreciated. Thanks!