Force download, hide pathThis 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 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 link:
Right click on link and from 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 web.
The reason for this is that several file types are opened directly within 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 operating system, browser software and plugins visitor has installed and while opening those files instantly might be intended behavior in many cases, sometimes you want a file to be downloaded.
One solution could be to pack file as ZIP or GZIP archive. In fact you should pack all your download files because it can save your bandwidth and reduce download time for your visitor. On 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 file size significantly in most cases.
What is 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 target audience. Especially when it comes to visitors with little experience in using internet, you end up writing support e-mails instructing visitors how to unpack ZIP or GZIP archive.
Another solution would be server side scripting. Scripting languages like PHP provide possibility to tell a browser not to open a file but download it to visitor's local computer. These scripts force browser to open save file as dialogue automatically.