Download file

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

  1. Hi!

    I am working on a peice of code that will allow a user to download a
    file located in the users folder. The file is NOT located inside the
    HTTP PUB so I need to use the FSO to stream it to them. For some reason
    the code finds the file but the download fails...

    ERROR: Internet Explorer cannot download downloadpdf.asp?code=OR1EC1
    from mirror.***.com

    Internet Explorer was not able to open this Internet site. The
    requested site is either unavailable or cannot be found. Please try
    again later.

    CODE:
    Set objFile = objFSO.GetFile(strFileName)
    Response.Clear()
    Response.AddHeader "Content-Disposition", "attachment; filename=" &
    objFile.Name
    Response.AddHeader "Content-Length", objFile.Size
    Response.ContentType = "application/octet-stream"
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open
    objStream.Type = 1
    Response.CharSet = "UTF-8"
    objStream.LoadFromFile(strFileName)
    Response.BinaryWrite(objStream.Read)
    objStream.Close
    Set objStream = Nothing
    Set objFile = Nothing

    Thanks,
    Andrew J Durstewitz

    * * * Sent via DevBuilder http://www.devbuilder.org * * *
    Developer Resources for High End Developers.
     
    Andrew Durstewitz, Jul 1, 2003
    #1
    1. Advertisements

  2. Andrew Durstewitz

    Bullschmidt Guest

    Don't know if this would help any but I would think that this:
    objStream.Type = 1

    Should go before this:
    objStream.Open

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
     
    Bullschmidt, Jul 1, 2003
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.