[thelist] Downloading .jpg & .pdf files

deke web at master.gen.in.us
Sun May 20 13:54:23 CDT 2001

On 19 May 2001, at 16:59, JTocher posted a message which said:

> Question #1 - Is there anyway in straight HTML (or with a smattering of
> javascript) to download the file when the appropriate link is clicked
> instead of opening it in the browser? I know the file can be 'zipped' which
> will download instead of open the file - was wondering if this is the only
> solution.

This isn't something you do in HTML, this is something you do in 
server configuration. When the browser sees a MIME type it doesn't
recognize, it asks the user where to save the file, rather than trying
to open it.

With an NCSA-compatible server like Apache, you simply put a files
in a special download-only directory, and stick an .htaccess file in
that directory for each file type:
    AddType application/octet-stream jpg
    AddType application/octet-stream pdf

Since the application/octet-stream MIME type is simply a stream of 
8-bit data of unknown use, there aren't going to be any applications
set up to open it. If you want to have fun, you can use 
    AddType application/evolt-download-only jpg
    AddType application/evolt-download-only pdf
or even
    AddType be/mine jpg
    AddType true/love pdf
> Question #2 - Is there any way to 'override' the default download directory
> set in the browser so files downloaded from this site will go into their own
> folder?



 "The church is near but the road is icy; 
  the bar is far away but I will walk carefully." 
                            -- Russian Proverb

More information about the thelist mailing list