Jump to content

Archived

This topic is now archived and is closed to further replies.

infratl

PHP file download script

Recommended Posts

Hi,

I'm designing a login system in which users can login and download manuals in PDF format. I created a script called "dealer.php" in the world readable web directory that calls other scripts that are in a directory called "dealers" that has an htaccess file that denies access from all. Therefore, the files in the "dealer" directory are only accessable via a script, which I'm doing through "dealer.php".

My problem now is how to make the browser download a file that is in the directory "dealers/products/pdf" since the "dealers" directory is denying access from all and causing all subdirectories to do the same. In other words, how can I make a PHP script that will make the browser download a file that is in a htaccess restricted directory?

I've read about using the header "content-type: application/force-download" or something similar, then using fopen with echo or just readfile to output the contents of the file to the browser. I'm not sure this is the best approach though.

Any ideas would be greatly appreciated.

Thanks.

Share this post


Link to post
Share on other sites
using the header "content-type: application/force-download" and then reading the file is probably the the only way to let a PHP script control downloads.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.