File upload permission errors

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ranger3
Forum Newbie
Posts: 6
Joined: Mon Oct 22, 2007 3:55 am

File upload permission errors

Post by ranger3 »

I get two warnings when attempting to upload a file to the images directory in the DocumentRoot for a virtual host in Apache2:
Warning: move_uploaded_file(/home/vsftpd/nameofsite/www/images/icon1.gif) [function.move-uploaded-file]: Failed to open stream: Permission denied...
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php6oPKJ2' to '/home/vsftpd/nameofsite/www/images/icon1.gif'...Error: could not move file to destination directory
The DocumentRoot is set to /home/vsftpd/nameofsite/www.

I have searched for information on the permission errors and how to avoid them but keep going round in circles. Any help on this much appreciated.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Try

Code: Select all

chmod 0777 /home/vsftpd/nameofsite/www/images
There are 10 types of people in this world, those who understand binary and those who don't
ranger3
Forum Newbie
Posts: 6
Joined: Mon Oct 22, 2007 3:55 am

Post by ranger3 »

Thank you for the reply - your suggestion worked! Much appreciated.

My only concern now is the security implications of chmod 0777. Does this mean that anyone can upload anything to the images directory, or is the upload restricted to only those users who have access to the php upload script (ie by logging into the website as administrator)? Bit hazy on this...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves 644 or 655 works fine for uploads.
Post Reply