Accessing a page as shown above will (usually) cause the browser to offer to save a copy of the file rather than trying to display it. The exact behavior depends on the browser and the user's choice of browser options. For example, suppose you want to offer a download of this current file, the link would be
/scripts/download.php?dir=/pictools/doc/&file=download.php
On my FireFox, clicking the above link brings up a dialog box asking whether to save the file of view it with wordpad
. For some file types, notably pictools.tgz
, the file is simply saved.
This script is usually not needed for most "unusual" types like .jar
files.
They will download with a simple
<a href="filename.jar">
Here, "unusual" means that the type is one that the browser has not been told how to process. Since users can instruct browsers how to deal with any type, if you want to ensure downloading, it is safest to use download.php
.
Restriction: Except for a limited set of types, downloading is restricted to files listed in the downloadable
property in their directory. See properties.php:downloadable.
Download.php
calls the sendpage
method in mimetype.php. Passing true
for the second argument means that the file is sent with a Content-Disposition
header calling for the file to be saved rather than displayed.