forced file download

Discussion in 'ASP General' started by dany, Jul 1, 2003.

  1. dany

    dany Guest

    Wrote a script (tried to;) which should force to download a pdf-file, but it
    doesn't work on every browser.
    What should be changed ?

    SCRIPT:
    ---------

    <%
    Dim Stream
    Dim Contents
    Dim strFileName
    Dim strFilePath

    strFileName = "download.pdf"

    strFilePath = Server.MapPath(strFileName)

    Response.ContentType = "application/octet-stream"
    Response.AddHeader "content-disposition", "attachment; filename=" &
    strFileName

    Set Stream = server.CreateObject("ADODB.Stream")
    Stream.Open
    Stream.LoadFromFile strFilePath
    Contents = Stream.ReadText
    Response.BinaryWrite Contents
    Stream.Close
    Set Stream = Nothing
    %>

    TESTED ON:
    --------------
    PC:
    IE6+: ok
    OPERA7+: ok

    NS7+: gives a saveas-popup but adds ".asp" to the file "download.pdf" =>
    download.pdf.asp
    MOZ1.2+: same as NS7
    OPERA6+: don't work, displays a lot off sh*beep*t

    MAC
    SAFARI: ok
    IE5.2: gives popup but pdf can't be opened due to decoding-error?
     
    dany, Jul 1, 2003
    #1
    1. Advertising

  2. dany

    dany Guest

    "Don Verhagen" <> wrote in message
    news:bdt293$10sgli$...
    >
    > "dany" <> wrote in message
    > news:vmkMa.1324$-ops.be...
    > > Wrote a script (tried to;) which should force to download a pdf-file,

    but
    > it
    > > doesn't work on every browser.
    > > What should be changed ?

    >
    > Doesn't work would mean?
    >
    > Every browser? What browsers? What Versions? What OS's?


    Did you look at the bottom of the message under the script???

    >
    > Don
    >
    >
    >
    > >
    > > SCRIPT:
    > > ---------
    > >
    > > <%
    > > Dim Stream
    > > Dim Contents
    > > Dim strFileName
    > > Dim strFilePath
    > >
    > > strFileName = "download.pdf"
    > >
    > > strFilePath = Server.MapPath(strFileName)
    > >
    > > Response.ContentType = "application/octet-stream"
    > > Response.AddHeader "content-disposition", "attachment; filename=" &
    > > strFileName
    > >
    > > Set Stream = server.CreateObject("ADODB.Stream")
    > > Stream.Open
    > > Stream.LoadFromFile strFilePath
    > > Contents = Stream.ReadText
    > > Response.BinaryWrite Contents
    > > Stream.Close
    > > Set Stream = Nothing
    > > %>
    > >
    > > TESTED ON:
    > > --------------
    > > PC:
    > > IE6+: ok
    > > OPERA7+: ok
    > >
    > > NS7+: gives a saveas-popup but adds ".asp" to the file "download.pdf" =>
    > > download.pdf.asp
    > > MOZ1.2+: same as NS7
    > > OPERA6+: don't work, displays a lot off sh*beep*t
    > >
    > > MAC
    > > SAFARI: ok
    > > IE5.2: gives popup but pdf can't be opened due to decoding-error?
    > >
    > >
    > >
    > >

    >
    >
     
    dany, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren

    Forced Download of PDF

    Darren, Mar 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    384
    Darren
    Mar 3, 2005
  2. Replies:
    1
    Views:
    469
    =?Utf-8?B?bGF0aGEgdmFsbGluYXlhZ2Ft?=
    May 5, 2005
  3. xeroxero

    ASP.NET Forced Download Not Working

    xeroxero, Jan 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    522
  4. dany

    forced PDF-download in popup

    dany, Jun 30, 2003, in forum: ASP General
    Replies:
    1
    Views:
    127
    Tom Kaminski [MVP]
    Jun 30, 2003
  5. MyndPhlyp
    Replies:
    20
    Views:
    284
    Roland Hall
    May 24, 2005
Loading...

Share This Page