views:

35

answers:

1

Hi there just wondering;

How do I deny direct access to files in a specific folder. I have an upload script that uploads to /uploadedFiles and currently I just have an index.php which redirects the user to the login page. However, how do I stop users from accessing a file directly such as:

/uploadedFiles/thisFile.jpeg

Thanks in advance :)

A: 

If you do not want your files to be accessed via the webinterface, add a .htaccess file with the following content:

Order deny,allow
Deny from all
Marcel J.
Is there any way to allow users that have signed into the website to access the files in the directory but not those who haven't authenticated?
Garbit
Unless you use BasicAuth for your login procedure, you might to try to send the file via your application (readfile in PHP, sendfile in Ruby/Rails or X-Sendfile). Those methods do not check the contents of the `.htaccess` file.
Marcel J.