Upload file permissions issue

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
masterkrang
Forum Newbie
Posts: 10
Joined: Wed Jan 23, 2008 6:45 pm

Upload file permissions issue

Post 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.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Re: Upload file permissions issue

Post 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.
masterkrang
Forum Newbie
Posts: 10
Joined: Wed Jan 23, 2008 6:45 pm

Re: Upload file permissions issue

Post 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
Last edited by Weirdan on Sat Mar 22, 2008 9:43 pm, edited 1 time in total.
Reason: code tags
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Upload file permissions issue

Post 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.
Post Reply