Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download a pdf without right-clicking the link

Status
Not open for further replies.

jatkinson

Technical User
Nov 14, 2001
406
0
0
GB
How can I create a hyperlink to open a save as box for a pdf file so a user can save it to their computer.

I know they can right-click on the link and select save target as.. but I can't assume that my site visitors will know this. Isn't their some script I can put into my html to do this, so visitors only have to click on the link to get the box??
 
Did you try changing the http:// to ftp:// just a guess, never tried it myself.



É
<!--#include file=&quot;profound quotation&quot; -->
 
As far as I know, there is no easy way to do this. Wait a second, I don't know any way at all. Sorry, I can't help. Ryan
rmindorff@hotmail.com
 
Further research has led me to believe this is not possible. However, a possible workaround is to put the file for download into a zip folder and link to that.

Another example of technology deciding that it knows what is best for the user!! ;-)
 
Hi,

Cian has came up with one of the best solutions to this..

But.. To do this you will have to have an anonymous FTP server set up.. Just simply changing the http to ftp will not give them access to the files on your site..

The other solution is the zip the file and then the user will always be prompted to download it..

Hope this helps Wullie

 
Or if you can use Server-Side Scripting ASP PHP etc you can trick the browser into downloading by sending out certain header information. Regards

Big Bad Dave

logo.gif


davidbyng@hotmail.com
 
Why not call the pdf directly? <a href=&quot;document.pdf&quot; target=&quot;_blank&quot;>. The user may want to read the pdf before saving it anyway. Tell the user they will need Acrobat reader and away you go.

Tom
 
There is no easy way of doing this!

The best way would be to inform the user that they have to right click and then choose save as from the menu!!

Just right it next to the button or somthing?

Andhow about adding a little script that when/if the user trys to left click the button (eg CLICK TO DOWNLOAD) Then there is a pop up message that says you have to right click and save target as.... etc

just an idea. I do think that someone has to come up with abetter way for us to use this on sites!! lol

James
Please see my site at:
 
With respect to BigBadDave's post, the HTTP header you're looking for here is
Code:
content-disposition
. This is a header that tells the user-agent (browser) whether the link should be loaded inline (if possible) or whether it should be treated as an attachment, i.e. download it and prompt the user to save it. The problem is, you have to have access to the HTTP headers to be able to do this. Any web application language I have ever used (ASP, ColdFusion, PHP, etc.) has a way to do this. Proper headers are as follows:

To view inline, if possible:
Code:
Content-Disposition:inline

To show a download dialog:
Code:
Content-Disposition:attachment

You can also specify other parameters, like a suggested filename, with this header. For more information, see
Note that a few browsers, notably IE5.5 pre-SP1 and IE4.01, have had some problems with processing this header correctly. For more information on these issues, see the following pages:

IE5.5: Fails for Known Content Types (Q267991)

IE4.01: Does not Force File Download Dialog (Q182315)

Hope this helps.

(Incidentally, anybody know if there is any way to make those links to the KB work in this forum? They seem to break at the semicolon.)
 
If the people viewing your site use Netscape, then put a sentance saying hold shift while clicking link this will automatically spawn the save dialog box, and it works for every kind of file. Only works in Netscape. [deejay]
Nate
&quot;If you're not living on the edge, you're taking up too much space!&quot;
 
Thanks for all the help especially pcorreia will check that out. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top