Hello,
I use the normal getfile.asp function to download files.
as long as the size is about 2 MBytes everything works fine.
Is the filesize is for example 4MBytes, the download will run endless without error message.
All variables and expressions I checked in getfile.asp are okay.
It's funny, but upload of big files is without problems. With rsPic(0).ActualSize I get the correct
value for 4MBytes.
The bug happens in the following lines of getfiel.asp ...
Response.ContentType = ContentType
Response.AddHeader "Content-Disposition", "attachment;Filename=" & strFileName
Response.AddHeader "Content-Length", rsPic(0).ActualSize
Response.BinaryWrite binTemp
I'm using MYSQL 5.0 with ODBC 3.51.06 under Windwos 2003 web Edition Server.
The field is a longblob field.
Any idea where to change a system value to get download run ???
Many greetings
Uwe Pfeiffer
<%
strConnection = "Provider=MSDataShape;DSN=ASP" & ucase(Session("Database")) & ";UID=root;PWD=root"
Dim oleHeaderSize, binImage
Dim lngImageSize, binTemp
Dim nSkip
Response.Expires = 0
Response.Buffer = True
Response.Clear
' connect to the database
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.ConnectionString = strConnection
oConnection.ConnectionTimeout = 7
oConnection.Open
' table and where clause needs to be dynamic
sSQL = "SELECT " & AddWrappers(Request("picfield"))
strFileName = Request("filename")
if strFileName="" then
strFileName = "'file.bin'"
else
strFileName = AddWrappers(strFileName)
end if
sSQL = sSQL & ", " & strFileName & " FROM " & AddWrappers(Request("pictable")) & " " & "WHERE " & Request("where")
Set rsPic = oConnection.Execute(sSQL)
binTemp = rsPic(0).GetChunk(rsPic(0).ActualSize)
strFileName = rsPic(1)
if IsNull(binTemp) then
response.end
end if
strFileType = lcase(Right(strFileName, 4))
' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp"
Case ".pdf"
ContentType = "application/pdf"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
Response.ContentType = ContentType
Response.AddHeader "Content-Disposition", "attachment;Filename=" & strFileName
Response.AddHeader "Content-Length", rsPic(0).ActualSize
Response.BinaryWrite binTemp
rsPic.Close
Set rsPic = Nothing
oConnection.Close
Set oConnection = Nothing
Response.End
function AddWrappers(strName)
if (InStr(1, strConnection, "Microsoft Access")>1 or isnumeric(strName) or InStr(strName, " ")>0 or InStr(strName, "'")>0 or InStr(strName, "")>0 or InStr(strName, "-")>0 or InStr(strName, "#")>0 or InStr(strName, ")")>0 or InStr(strName, "(")>0 or InStr(strName, "/")>0) and Left(strName,1)<>strLeftWrapper then
AddWrappers = strLeftWrapper + strName + strRightWrapper
else
AddWrappers = strName
end if
end function
%>