Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 need to upload a file to site with PHP code. How to set permission for upload folder if I want to users cant access to file by URL but PHP code read this file ?

share|improve this question
Which OS are you using? Which web server? (Lighttpd and Apache tips won't be much use if you're running IIS) – danlefree Apr 20 '11 at 14:44

If possible best way to do that is to put your uploaded files outside of your webroot. That way the files won't be accessible by url but your scripts can still access them.

share|improve this answer

The www (or whatever account is used to run your web server) account needs to have write access to the directory. I would assume that you could block direct access to said directory through an .htaccess file placed in that directory.

It might look something like:

Order deny,allow
Deny from all
share|improve this answer

Try chmod 750 on the directory, which will give you full access, the server/program read + execute access, and users no access.

share|improve this answer

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.