Page 1 of 1

Upload file permissions issue

Posted: Sat Mar 22, 2008 3:42 am
by masterkrang
Hi, I am trying to write a page that simply uploads images to my server through a web browser. The place I found the code is on php.net here: http://us2.php.net/features.file-upload

The code there seems straight forward, but I can't get it to work. The issue occurs on this line in my code:

@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $upload_filename)
or error('receiving directory insuffiecient permission', $upload_form);

Obviously, ther is a permission issue on the server, as the error portion of my script outputs "receiving directory insuffiecient permission".

I have changed a few things on the Linux server, for example I followed a recommendation on from the link above that said to chown nobody upload_dir. That didn't work. I also changed the permission of the uploaded_images directory to 0777 temporarily, and that didn't help. Just trying to debug this script but I don't know what the next step. Any help? Thanks.

Re: Upload file permissions issue

Posted: Sat Mar 22, 2008 7:26 am
by Rovas
Remove the @ from the function move_uploaded_files to see what error it gives. @ removes the error and notice messages that the function returns.

Re: Upload file permissions issue

Posted: Sat Mar 22, 2008 8:38 pm
by masterkrang
Here are the error messages: Thanks.

Code: Select all

/home/webadmin/funnotfame.virtual.vps-host.net/html/admin/print_photos/
Warning: move_uploaded_file(/home/webadmin/funnotfame.virtual.vps-host.net/html/admin/print_photos/) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/webadmin/funnotfame.virtual.vps-host.net/html/admin/upload_processor.php on line 53
 
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpXQW3A5' to '/home/webadmin/funnotfame.virtual.vps-host.net/html/admin/print_photos/' in /home/webadmin/funnotfame.virtual.vps-host.net/html/admin/upload_processor.php on line 53
Upload failure
 
An error has occured: receiving directory insuffiecient permission... The upload form is reloading

Re: Upload file permissions issue

Posted: Sat Mar 22, 2008 9:42 pm
by Weirdan
How you construct $upload_filename ? move_uploaded_file() expects both arguments to be filenames and it seems the second argument you're passing to it is a directory name, which is wrong.