Get Adobe Flash player


Search this site for:

Related Links

Valid XHTML 1.0 Transitional

Valid CSS!

Force the download, hide the path

Force the download, hide the path

This is an article about providing downloads on a website. It describes common webmaster issues when it comes to file downloads and it will discuss several solutions. Some of them are easy to implement, others require a little technical background and programming skills. But in the end, everyone will have a suitable solution for his problem.

If someone wants to provide a download on his website, one can find following instruction note beside the link:

Right click on the link and from the context menu, select "Save Target As" in Internet Explorer or "Save Link As" in Netscape/Mozilla.

If you search in Google for "right click" "save link as" OR "save target as", you will get around 1,750,000 search results. It seems to be very common in the web.

The reason for this is that several file types are opened directly within the browser window (JPG, GIF, MP3, MPG, AVI, PNG, TXT, PDF, and of course HTML). Other file types start an extern application (XLS, DOC, PPT). It depends on the operating system, the browser software and the plugins the visitor has installed and while opening those files instantly might be the intended behavior in many cases, sometimes you want a file to be downloaded.

One solution could be to pack the file as ZIP or GZIP archive. In fact you should pack all your download files because it can save your bandwidth and reduce the download time for your visitor. On the other hand, packing files like JPG, GIF, MP3, or AVI does not make much sense because these file formats are pack formats itself. Packing these files into a ZIP file will not reduce the file size significantly in most cases.

What is the downside of a pack format like ZIP or GZIP? Not everyone has a software to unpack them on his local computer and therefore you would loose some of the target audience. Especially when it comes to visitors with little experience in using the internet, you end up writing support e-mails instructing visitors how to unpack the ZIP or GZIP archive.

Another solution would be server side scripting. Scripting languages like PHP provide the possibility to tell a browser not to open a file but download it to the visitor's local computer. These scripts force the browser to open the save file as dialogue automatically.

If you have some programming skills, you can go to (, get all the needed information there and write a tool that serves the download file to the visitor along with the instructions to force the browser to open the download dialogue.

If you do not have the programming skills, you are either lucky to know that programming guy above or to know websites like Those websites offer "ready to use" CGI or PHP scripts for implementing in your own website. ( created such a tool in 2003 and has improved it as user feedback came in. That tool, named Download Center Lite (, is a small package that needs to be installed on your web server. You only need to define the path to your download files directory and do some other optional configuration.

Once installed you can link to the script and attach the name of your download file to the link URL using a question mark:

The script looks up the file name within the download folder and outputs it to the visitor. Download Center Lite has been tested and proven to work with small (few KByte) and even large files (over 100 MByte).

Another important built in feature is that the script hides the real download path. That prevents the visitors from accessing your download directory directly. You could even place the download folder outside of the www root folder.

Admittedly, while most of the web browsers on most of the operating systems work fine with the script, there are some exotic combinations of browsers and operating systems that will still open the file directly instead of opening the save as dialogue. Fortunately, these browsers (i.e. IE 4) have a very small market share, so no need to worry about that much.

About the Author
The author is a freelance software developer and web designer (