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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.