I have a php script which uploads images to a folder.

I have these permissions on the upload folder:

  drwxrwxr--  4 user user   4096 2010-06-02 16:20 temp_images

Shouldn't these permissions be enough for files to be uploaded to the folder?

But this doesn't work.

It only works when I set the permissions to 777.

"user" is added to the www-data group, still no luck.

Any ideas why?


Your folder is owned by the user and group user. If apache is running as a different account, perhaps www-data then apache will not be able to write there. Adding the user account to the www-data group would mean that user is permitted to write in folders that the www-data group owns and is set for rw. If you want apache to write to the folder the group user owns the apache service account must be a member of the user group.


If safe_mode is on, then user should be the apache/php user unless you set safe_mode_gid to on where check is done on group instead of user

  • what do you mean? if safe_mode is off, then apache user doesn't matter? – Anonymous12345 Jun 2 '10 at 15:23
  • see Zoredache answer, I miss readed something in your question – radius Jun 2 '10 at 18:09

The owner of the directory should be the effective userid of the web servers. Try changing the ownership, then you can set the permissions to 700, 750, or 755.

chown www-data temp_images

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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