Jump to content

PHP file download script


infratl

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.