Page 1 of 1

Protecting files without htaccess

Posted: Wed Feb 21, 2007 9:13 am
by thiscatis
Hello,

is there a PHP way to protect files, jpegs, pdf`s etc.. without htaccess because i already use a custom login/member management.
So the files are login-protected even when they know the exact link to the file.

Thanks!

Posted: Wed Feb 21, 2007 9:15 am
by feyd
If the exact link to the file is known.. nope. Use a script as the interface into the files. Place an .htaccess in their directory that disallows all access (not password protection).

Posted: Wed Feb 21, 2007 9:22 am
by Kieran Huggins
...or move them outside the web root, but everything else is exactly as feyd suggested: use a gateway/interface script that authenticates and initiates the download.

Posted: Wed Feb 21, 2007 9:22 am
by thiscatis
so for example:

I have a gallery that loads images from the /gallery/ folder.
I place a htaccess in the /gallery/ folder to prevent direct access.
So people will need to be in the gallery system to view the pictures.
Will that work? or will the htaccess prevent the script from loading pictures.

(gallery/picture as example, could be something else too)

Posted: Wed Feb 21, 2007 9:26 am
by feyd
The .htaccess file will not stop PHP from reading the directory, only requests Apache would handle.

Posted: Wed Feb 21, 2007 9:27 am
by thiscatis
Great, I`ll know what i'll be making today :)
You guys are better than google, learned a lot here, thanks!