PDA

View Full Version : Downloading file using asp



Techy
07-09-2006, 11:28 AM
Hi,

I have a script which records how many times a file has been downloaded. Then the file is downloaded.

I pass the filename like this:

download.asp?file=document.pdf

The code in download.asp is: (minus the database code as it's quite long)




Response.Redirect("/documents/" & Request("file"))



Clicking with the left mouse button works fine in all browsers, but there is always going to be someone who clicks with the right, and selects 'save target as' This works in IE and Opera, but Firefox saves the file as 'download.asp' If the asp extension is then renamed to .pdf the file opens okay.

Does anybody know how to get Firefox to download the file with the correct name and extension?

Many thanks.

Twey
07-09-2006, 11:54 AM
You could try using the headers:
Content-Type: application/x-pdf
Content-Length: <length of file in bytes>
Content-Disposition: attachment; filename=document.pdf... then simply outputting the file to the browser.

Sorry, I don't know ASP, so I can't write that up.