« Previous Next »

Thread: download problems

Last post 06-15-2009 10:59 AM by tomkmvp. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 06-12-2009, 8:56 PM

    download problems

    I'm having issues with the below. When a dialog box opens I opt to save the
    file, but all I get is a 0 length file. Files should be 3MB+. I write FPath
    to the screen and the link is correct. I can cut-n-paste to a browser
    address bar and download the file as expected.

    Is there a way to write FPath to the dialog box so I can see what's
    happening there? Otherwise, what am I doing wrong here?

    thanks!

    <%
        Response.Buffer = False
        Server.ScriptTimeout = 30000

        Response.ContentType = "application/x-unknown" ' arbitrary
        fn = (rsFreeDownload.Fields.Item("FileNam").Value)
        FPath = "http://www.xyz.com" &
    (rsFreeDownload.Fields.Item("Folder").Value) & fn
        Response.AddHeader "Content-Disposition", "attachment; filename=" & fn

        Set adoStream = CreateObject("ADODB.Stream")
        chunk = 4096
        adoStream.Open()
        adoStream.Type = 1
        adoStream.LoadFromFile(FPath)

        iSz = adoStream.Size

        Response.AddHeader "Content-Length", iSz

        For i = 1 To iSz \ chunk
            If Not Response.IsClientConnected Then Exit For
            Response.BinaryWrite adoStream.Read(chunk)
        Next

        If iSz Mod chunk > 0 Then
            If Response.IsClientConnected Then
                Response.BinaryWrite adoStream.Read(iSz Mod chunk)
            End If
        End If

        adoStream.Close
        Set adoStream = Nothing

        Response.End
    %>


  • 06-13-2009, 11:41 AM In reply to

    Re: download problems

    Addendum: I think I know what the problem is, but not sure how to remedy. When I was on a dedicated server, my FPath was on the same machine and all worked fine.

    I have since moved to a shared server, but my downloads are on another server entirely. So, instead of FPath="C:\myfiles\etc.", it's now FPath=http://www.myotherserver.com/myfiles/etc.

    I don't want to disclose where the file is being downloaded from. Can the above be modified to do that?

    thanks!

  • 06-15-2009, 10:59 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,189
    • IIS MVPs

    Re: download problems

Page 1 of 1 (3 items)
Microsoft Communities