Jump to content


PHP file download script

  • Please log in to reply
1 reply to this topic

#1 infratl

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 23 June 2006 - 08:20 PM


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.


#2 dptr1988

  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 24 June 2006 - 02:34 AM

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.
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users