I recent started receiving errors when downloading files stored in a database and sent to the browser on a Classic ASP page (although the problem may occur in other languages as it appears to be a Chrome issue).
My original ‘downloader’ script below pulls the binary file data and related key information from a database and sends it to the browser:
SET fetchFileDataRS = readOnlyConn.Execute ("SELECT contentType, fileBinary, downloadFileName, sizeInKb FROM CUSTOMER_files WHERE downloadID = " & downloadID,,adCmdText) Response.Expires = 0 Response.Buffer = TRUE Response.Clear Response.AddHeader "Content-Disposition","attachment; filename=" & fetchFileDataRS("downloadFileName") Response.BinaryWrite(fetchFileDataRS("fileBinary")) Response.Flush Response.End SET fetchFileDataRS = NOTHING
To solve the problem, I simply added a REPLACE to the script to strip out commas from the filename sent to the browser:
SET fetchFileDataRS = readOnlyConn.Execute ("SELECT contentType, fileBinary, downloadFileName, sizeInKb FROM CUSTOMER_files WHERE downloadID = " & downloadID,,adCmdText) Response.Expires = 0 Response.Buffer = TRUE Response.Clear Response.AddHeader "Content-Disposition","attachment; filename=" & REPLACE(fetchFileDataRS("downloadFileName"), ",", "-") Response.BinaryWrite(fetchFileDataRS("fileBinary")) Response.Flush Response.End SET fetchFileDataRS = NOTHING