PDA

View Full Version : Adding a Download Link



Cheng
09-23-2006, 09:06 AM
Hi.

I want to add a download link to a PDF file for example that is on my webserver so that if someone clicks on that link that the file will be downloaded and not opens up in a browser window.
Can someone tell me how to configure a link like this please?

Thank you very much.

Cheng

djr33
09-23-2006, 09:42 AM
PDFs are downloaded by default. Only plugins support "opening them in a browser". Acrobat reader kinda embeds itself into the browser to act like it's opening in it, but it's just an annoyingly scaled down version of the standalone application.

So, because of this, it will be hard to control the way it's handled by the browser.

Using php, you can specify a filetype and tell the browser to download, not open, the file, but Internet Explorer just ignores this.
This means there isn't really a way, but you could use php to make it do so for those users not using IE.

Cheng
09-23-2006, 09:58 AM
.......thanks for your reply.
So it seems there is no way to get it done in general.
Could it be done with a selfextracting exe file?
I think that could be a option or is it not?
Thanks again for your help.......Cheng......

djr33
09-23-2006, 11:18 AM
As I said, you can specify that it's a "force-download" type link using php, though IE will ignore that. That's as close as you'll get.

However, yes, you can use another file type that won't open, like a self extracting exe or zip. I'd highly recommend zip over exe because 1. zips aren't as dangerous as exes. Unless people really trust you, they likely won't want to run an exe as that is a huge security risk. A zip, on other hand, is a lot less of a risk, and is still quite compatible. 2. zips are mac compatible.

Anyway, yeah, that's the way you'd force a download if you need it to not be able to open in the browser.

Birmingham
09-23-2006, 12:01 PM
you could put a statement next to the link saying that if it doesn't automatically download when clicked, to right click it and choose "save target as". ... or put that advice in a link called "can't download?"...or something similar.

good luck!

mwinter
09-23-2006, 08:51 PM
As I said, you can specify that it's a "force-download" type link using php ...

If you're referring to "application/force-download", do not use that. If one is to "invent" content types, they should use the experimental/private prefix.

To specify content is arbitrary binary data (for download), it should be labelled "application/octet-stream". Ideally, though, the content type sent will be accurate (that is, application/pdf), and the user should choose either explicitly (selecting a "Save As..." option) or implicitly (instruct their browser how to handle the type).

Mike