Hello -
Seems like I am having a renaming issue. I am able to get the file onto my server moved to the right directory and permissions changed to 0766 but from that point on everything stops working. below is a copy of the script:
error_reporting(E_ALL);
$uploaddir = '/www/vhosts/website.com/htdocs/photos/';
$uploadfile = $uploaddir . $HTTP_POST_FILES['userfile']['name'];
$filename1 = $HTTP_POST_FILES['userfile']['name'];
$newname = "picture1";
print "<pre>";
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $uploadfile)) {
chmod ($uploaddir . $HTTP_POST_FILES['userfile']['name'], 0766);
rename($uploaddir . $HTTP_POST_FILES['userfile']['name'], $newname);
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($HTTP_POST_FILES); // THIS IS LINE 23
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($HTTP_POST_FILES);
}
print "</pre>";
The error that I am getting is this
Warning: Rename failed (Permission denied) in /usr/local/www/vhosts/website.com/htdocs/upload.php on line 23
File is valid, and was successfully uploaded. Here's some more debugging info:
Array
(
[userfile] => Array
(
[name] => T&J.jpg
[type] => image/pjpeg
[tmp_name] => /var/tmp//phpA31ahu
[size] => 25734
)
)
Any Ideas?? Also, I am guessing even if I can rename it, the file extension will be missing, does anyone know how to correct that issue as well. I have a hunch that I will have to break the file name abart and asign the extention to a seperate variable and attaching it to the end of the file name. If anyone could provide and example of how this is done that would be great!
(Permissions for the Photos folder is 777)
Thanks! 🙂