Results 1 to 2 of 2

Thread: Downloading file using asp

  1. #1
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Downloading file using asp

    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)

    Code:
    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.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You could try using the headers:
    Code:
    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •