Download file in chunks

I

Ilia Makarenko

Hi everyone!

I've got a problem with IIS 6.0 when downloading files with size > 4
Mb. So I am trying to download file in chunks, but it doesn't work.
Only pert of the file is downloaded (~6.5 of 22.5 Mb). Here is the
code:

....

ext = right(filename, 3)
select case ext
case "pdf" ctype= "application/pdf"
case "exe" ctype= "application/octet-stream"
case "zip" ctype= "application/zip"
case "doc" ctype= "application/msword"
case "xls" ctype= "application/vnd.ms-excel"
case "ppt" ctype= "application/vnd.ms-powerpoint"
case "gif" ctype= "image/gif"
case "png" ctype= "image/png"
case "jpg" ctype= "image/jpg"
case else ctype= "application/force-download"
end select


Response.Buffer = False
Response.ContentType = ctype
Response.AddHeader "Content-Disposition", "attachment; filename=" &
f.Name & ";"

buffer_size = 3500000
data_to_read = f.Size

Response.AddHeader "Content-Length", CStr(data_to_read)

do while data_to_read > 0
Response.BinaryWrite ts.Read(buffer_size)
Response.Flush
data_to_read = data_to_read - buffer_size
loop

....

Could anyone tell me what's wrong with the code?

Ilia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top