WWW FAQ: How can the user download binaries (such as .ZIP and .EXE files) from my server?

How can the user download binaries (such as .ZIP and .EXE files) from my server?

There is no specialized <DOWNLOAD> tag in HTML. Just do two things: link to the binary in question using a normal <A HREF=...> tag, and make sure that your web server is configured to output a reasonable content type for .zip, .ZIP, .exe and .EXE files.

You probably do not want to edit the mime.types file of your server, because new versions of this file regularly become available with new versions of the web server. Instead, under the NCSA server and its derivatives, use the AddType and AddEncoding commands in your server configuration file. After making a change to your configuration files, always signal the server process to reexamine those files by using the kill -1 command.

Consider adding the following lines:

AddType application/zip zip
AddType application/zip ZIP
AddType application/octet-stream exe
AddType application/octet-stream EXE
In general, the content type application/octet-stream is an excellent choice when there is no appropriate "external viewer." A typical browser will then prompt the user to save the file. However, if there is a more appropriate content type, you should of course use that type instead.

On occasion, users may have encountered very badly behaved servers which encourage users to set up a specialized external viewer for the application/octet-stream content type. This makes life difficult for everyone. Programmers: please don't encourage users to configure an external viewer for application/octet-stream. That content type should be reserved for downloads. If you have created an external viewer for a brand-new form of information, invent a new and appropriate content type for your application's data and configure your server to output that content type. Make your content type known to the public aand to the authors of web servers so it can be added to the mime.types file.

"How do I suggest a filename?"

To encourage the user to save the file under an appropriate filename, do the following:
  • Tell the user exactly what name to save the file under, in case the web browser is not cooperative and suggests an absurd filename or no filename at all.
  • Make sure the URL the user is accessing actually ends in a reasonable filename. (This warning is intended primarily for CGI programmers. Under normal circumstances this is not a problem.)

"So I can use http to download binaries?"

Yes, and practically all browsers are bright enough to save them properly if you follow the suggestions above. It is not necessary to use the ftp protocol for binary downloads.
World Wide Web FAQ