Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download a file

Status
Not open for further replies.

Kennya1

Programmer
Joined
Apr 14, 2002
Messages
15
Location
US
I am sure this has been asked befor. I need html/PHP code that when some clkicks n a link it will download a file that I have on my web site. I would like the exact location of the file to be hidden

 
You can have PHP stream a file from your web server's filesystem to a web browser. One solution with example code can be found in the PHP online manual entry for fpassthru(). There is also example code on forcing a browser to open the "Save As" dialog box at the online manual entry for header() (see the last example script).

PHP's filesystem commands, of which fpassthru() is one, can operate on any file in the filesystem. They are not constrained to the current web site's document root.

So you can have your files anywhere on the filesystem and use the fpassthru()-using script send the files to the browser.

The trick to completing the solution is to have some mechanism by which your file-streaming script can map some arbitrary identifier to your file store.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top