Download file

Results 1 to 2 of 2

Thread: Download file

  1. #1
    Join Date
    Dec 1969

    Default Download file

    The user has the option to download the file that had been previously uploaded, I created a forced download so the user can choose where they would like to download the file. The problem is that I get an error. Any ideas?<BR><BR>ADODB.Stream (0x800A0BB9)<BR>Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.<BR><BR>Selects the file<BR><BR>&#039; // Checks Out Existing File<BR>Sub CheckOutFile(Upload_id)<BR> Set Cof = Server.CreateObject("ADODB.RecordSet")&#039;<BR> Cof.Open "Select * from Test where Upload_id = " & Upload_id, dbConn, 1, 3<BR> File_Name = Cof("File_Name")<BR> File_Name_Unique = Cof("File_Name_Unique")<BR> File_Size = Cof("File_Size")<BR> Date_Modified = Cof("Date_Modified")<BR> Display_Date = Cof("Display_Date")<BR> Cof.Update<BR> Cof.Close<BR> Set Cof = Nothing<BR> Path = Request.ServerVariables("Appl_Physical_Path") & "gbtaIncFiles\" & File_Name_Unique<BR> Call ForceDownload(Path, File_Size, File_Name)<BR>End Sub<BR><BR>Forces the download<BR><BR>&#039; // Alters the Content Disposition of the Response Header so that user is prompted for a location to save<BR>Const adTypeBinary = 1<BR>Sub ForceDownload(strFilePath, strFileSize, strFileName)<BR> Response.Buffer = True&#039;<BR> Response.Clear<BR><BR> Set objStream = Server.CreateObject("ADODB.Stream")<BR> objStream.Open<BR> objStream.Type = adTypeBinary<BR> objStream.LoadFromFile strFilePath<BR> Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName<BR> Response.AddHeader "Content-Length", strFileSize<BR> Response.Charset = "UTF-8"<BR> Response.ContentType = "application/octet-stream"<BR> Response.BinaryWrite objStream.Read<BR> Response.Flush<BR><BR> objStream.Close<BR> Set objStream = Nothing<BR> Response.Redirect("newtask1.asp")<BR> Response.End<BR>End Sub<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Download file

    try removing<BR>Response.AddHeader "Content-Length", strFileSize<BR>from the header. If you get no error then, the data type of strFileSize is wrong.

Posting Permissions

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