Hidden File Download
Hidden File Download
This article will show you how to make a link to download
any file on your server without revealing the file's
location.
It's a one-click download link.
But, why?
-
For short-term promotions, after which the link can
be removed, leaving the orignal file where it's at.
-
Maybe you're offering a link to download a real
working script.
-
It can come in handy to provide access to an
intermittently updated file without providing
FTP login information.
-
Files not otherwise accessible by browser can be
downloaded.
-
It's also very handy for personal use, instead of
FTP, for logs or other files frequently downloaded.
The download link would be on a web page stored on
the hard drive, not on the Internet.
The download link requires software on your server to send
the file contents to the browser. Complete software for PHP
and for Perl come with the article.
Choose which you prefer to use. Only one is needed.
If installing the PHP script, verify the PHP code is at the
beginning of the file. No spaces or other characters, and no
blank lines, may come before the PHP code. Otherwise, the
PHP code will be unable to send header lines to the browser.
Upload it to somewhere in your document directories.
If installing the Perl script, upload it to your server as a
plain text file (not binary), in a directory that can run
Perl scripts. Then, give the script 755 permissions.
In either case, the URL for your download link is the URL
to the script you installed. Construct the download link
just like you would any other link.
When the link is clicked, the download commences. In most
situations, the user will be asked where on their computer
to store the file. The web page itself does not change.
Notes:
If the downloaded file is of zero size, the script was
unable to open the file. Verify the value of $FileLocation
is correct.
If the script can't open the file at the location specified,
it will try to open the file relative to the document root
directory. If it still can't open the file, nothing will be
downloaded (resulting in a download file of zero size).
Will Bontrager
©Copyright 2007 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.