forcing asp download problems with large files
I use this code to force the download files:
file = Request.QueryString("file")
ContentType = "application/x-msdownload"
Response.Buffer = True
Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=" & file
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Set objStream = Nothing
it works very well !
But I have a problem with files size large ...
there is anyone to help me?
It depends on where your problem is.
If the file is too large to load into the stream with LoadFromFile then there is no easy answer.
If the problem is simply that your Response buffer is too small, then it's fixable.
objStream.Read can take one argument: The number of bytes to read. So you can do this in chunks.
In place of
In place of
Do While Not objStream.EOS
it works perfectly
Yes, same idea as what I gave. Simpler coding, but would be same result: Just do it in "chunks". But 4096 is a very tiny chunk size. Not very efficient. You really should try increasing the chunk size *A LOT* to find the optimum size.
|All times are GMT +1. The time now is 03:33 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.