PDA

View Full Version : users uploading images - permissions?


urg
04-16-2005, 01:18 AM
I'm trying to get a script going so users can upload their own images. I found one that seems right (resizes, renames, etc.) I'm testing it now. I get the error "permission denied..." on the line that tries to save the image. Is there a permission I need to set to allow the script to store an image file?

Thanks.
-Brett

f-stop
04-18-2005, 09:16 AM
You probably will need to CHMOD the folder that the images are being written into to allow it to be writable. It may be something more complicated, but that is what I would try first.

Viper007Bond
04-19-2005, 11:57 AM
That's probably it. A CHMOD of 777 will mostly fix it.

gbw4th
06-03-2005, 11:13 AM
Under the current server setup PHP runs as user 'nobody' (or at least that is the case on the server I am on). There are a couple of different ways you can solve the problem:

Make the upload dir world writeable. Downside here is that any other user on your server could potentially write into your upload dir then.
Create the upload dir using a PHP script. This way it will be owned by nobody and your upload script will have write permission to the dir.
You can try forcing your php to run as CGI script (http://us4.php.net/security.cgi-bin) (which run as your user instead of nobody)


Personally I would go with either B or C. Depends on how paranoid you are. I never actually tried doing C on a host rocket server but it should be possible.

Maybe if enough people ask for it they will consider install the suPHP apache module that enables mod_php to run as the user (similar to how suexec works for CGI) without having to play the CGI trick mentioned above.

Silmaril8n
06-03-2005, 12:52 PM
You can also create a directory, chmod it 777, then create a subdirectory in there using a PHP script. That will give ownership to the directory for the nobody user. Then, chmodd the first directory back to normal.