tags:

views:

83

answers:

2

Hello, I am trying to make it so when you click "download here" a pdf will download to their desktop. Could anyone please provide me with information on how I should go about doing this?

Sincerely,

Caleb

A: 

What you are asking is to control browser behavior - this is not simple.

The best bet you have it to point the link to what seems like a web page (i.e. download.php?file=1) and once the browser notices it's binary data, it will ask the user what it wants to do with it. This method will most likely get the job done.

But note that this behavior cannot be guaranteed, and is highly-dependent on browser configuration.

Yuval A
Since this method is not recommended how should I present the pdf? Should I copy and paste it onto the page? I've seen pdfs in web browsers, but I don't know how they do it. Also I'm just a beginner in web design. I have no clue what binary data is, sorry.Sincerely,Caleb
Nelsencaleb
+5  A: 

Use the Content-Disposition header.

But, please: Only do this if it is really necessary for the user to download the PDF and not open it (so that it's just an aid for the user that he does not have to explicitly select "save file"). Don't use it to force the user to download it although he just wants to view it.

Marian
Nice. Never used that header.
Yuval A