HTML Links that download

pedz

Registered
I would have thought this would be a frequently asked question but I can't find my answer anywhere (here or google)...

How do I make a link that instead of going to the destination, the file is downloaded? The Apple site can do this with their update packages. Is it because of the suffix? Or can I add some type of mine type to the <a> tag? It seems like either one would be browser specific.

For example, I have a tar gzip'ed file foo.tar.gz. I'd like to say
<a url=foo.tar.gz magicthingy=downloadme>Tar file</a>

Thanks,
 
You can't control what a user's browser does with an HTML link -- it's all dependent on the mime types set up by the server and on the user's machine.

Technically, there's no difference between the data for an HTML page and the data for a binary file being transferred to the user -- they're still bytes flying across the internet. What the user's browser decides to do with those bytes (display them, download them, etc.) is dependent on the mime types of the server and of the user's machine.

With that being said, a gzipped file should always download if the server has the correct mime types set.
 
Thanks. Two questions:

1) So it sounds like you are saying that I can not specify the mime type in the <a> tag? That way, I don't have to depend upon my server being set up right.

2) I'm running Apache 2.2. It sounds like I need to tweak something to teach it the mime type for a compressed gzip file. Do you know where I do that?

Thanks,
 
Back
Top