Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am unaware on the cons and pros of giving the directory permission to 0777, and i have left with no choice but to use the 0777 file permission to upload files on my server through my application.

the following file permission works for me to upload file 0757 and 0557. this means i can upload the file with the world or other permission and not from user or group.

is it safe for me to use that permission. if not what is wrong with the application, why is refusing to upload through user or group.

thank you

share|improve this question

migrated from Oct 17 '10 at 2:19

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

There are two solutions here, either set the directory to be 0777 as suggested in the documentation, or change the owner of the directory to the user under which PHP runs. The latter would allow you to run with more restrictive permissions, but it may not actually get you any more security if PHP is running under a web server, a it will be running as user _www or nobody or similar, the same as every other script that the web server will be running.

share|improve this answer

The owner of the directory must be the same as the user that the web server runs as. If the directory owner matches the server user then you should be able to upload with 0755 permission.

share|improve this answer
i am on a shared hosting, using the shared account, does my shared account recognize me as the owner or the other? – Ibrahim Azhar Armar Oct 16 '10 at 7:30
@Ibrahim: The easiest way to find the correct user is probably to run: ps aux | grep httpd. This way you can find out which user is "owning" the HTTP server. You need to chown your upload directory to that user. If you can't do that, talk to your hoster, he can surely help you. – DarkDust Oct 16 '10 at 7:44
I assume that the directory is currently owned by the shared account. Your application is not running as this user. It is running as the user of the web server. On my mac this user is _www. You can find out what the web server user is on your host by running 'ls -l' on the upload directory and seeing the owner for the files that were successfully uploaded. Then you would submit some sort of support ticket to your shared hosting provider to change the owner of the upload directory to that user and the permission to 0755. – MtnViewJohn Oct 16 '10 at 7:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.