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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click link to download

Status
Not open for further replies.

HumbleSeeker

Programmer
Nov 29, 2002
37
GB
I'm pretty sure this isn't possible, but the programming Gurus of this forum have surprised me before.

Is there anyway to have a link to a file and when the user clicks on it it brings up the save as screen rather then opening the file. The file in question is a pdf, so I can't count on it being downloaded.

Thanks for reading this, and thanks if you can help.

Humble Seeker
 
If a file has a MIME type that is recognised by the browser then the browser will open it. So yes, this isn't possible (as far as I am aware).
BDC.
 
The usual way in ASP would be to:

* Have the link point to an ASP file download page.

* Have the ASP page set the MIME type, and do something like:

Response.AddHeader "content-disposition","attachment; filename='test.pdf'"

* Stream back the file content using ADODB.Stream or something.

The "download page" could easily use a query parameter so you only need one special download-link page. Just make the links point to something like:

filedl.asp?type=pdf;file=test.pdf

And filedl.asp can pull out the type and file parameters.


Here is the best example of this sort of thing I can find right now. They explain a lot of it too, unlike your typical hunk of sample code:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top