473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

file size mismatch when downloading files...

Hi!

I am using the script below to download files, that are in a non-public
directory, from my site. The "smaller files" section works for smaller
files. However when the files are getting larger, it won't work! I'm not
sure what the size limit is, or if it is some kind of timeout, which would
mean very small files if the connection is slow (I'm working against a
server on the LAN).

When I try to download larger files with the "small file"-section, I only
get a fraction (a few bytes) of the file. The "Large files"-section however
transmitts the file correctly except for a FEW bytes. My testfile is
16.010.423bytes originally, but downloaded it is 16.009.507 bytes.

As I am explicitly setting the size of the file in the download I cannot
understand why this happens?!?

Server: Win 2003, IIS 6.0
Client: WinXP SP2

The code below is partially taken from this page:
http://www.aspfaq.com/show.asp?id=2161

First fFileName and fFullPath is set...

if fs.FileExists(fFullPath)=false then
Set fs=Nothing
Response.End
Else
Set objFileStream = fs.GetFile(fFullPath)
intFileLength = objFileStream.Size 'Size of file

Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open
adoStream.Type = 1 'Binary
adoStream.LoadFromFile(fFullPath)

'----------------- Larger files ------------------
If intFileLength > 2000000 Then '~2MB size limit
Response.Buffer = False
Server.ScriptTimeout = 30000

chunk = 2048
iSz = adoStream.Size

Response.ContentType = "octet-stream" '"application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" &
fFileName
Response.AddHeader "Content-Length", iSz

For i = 1 To iSz \ chunk
If Not Response.IsClientConnected Then Exit For
Response.BinaryWrite adoStream.Read(chunk)
Next

If iSz Mod chunk > 0 Then
If Response.IsClientConnected Then
Response.BinaryWrite objStream.Read(iSz Mod chunk)
End If
End If

adoStream.Close
Set adoStream = Nothing
'------------------- Smaller files -----------------
Else
Response.Buffer = True
Server.ScriptTimeout = 30000
Response.Clear
Response.ContentType = "octet-stream"
Response.AddHeader "Content-Disposition","attachment; filename=" &
fFileName
Response.AddHeader "Content-Length", intFileLength
Response.BinaryWrite(adoStream.Read(intFileLength) )
Response.Flush

adoStream.Close
Set adoStream = Nothing
Set objFileStream = Nothing
Set fs = Nothing

End If
End If
Response.End
Jul 22 '05 #1
0 2052

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James Whitehead | last post by:
I have the following code which works fine downloading smaller files, the trouble is most of the files to be downloaded are large. With large files it just returns a HTTP 500 error. Any ideas...
2
by: hoenes1 | last post by:
I've got an aspx-Page "SendFile.aspx" which is called by a Link on "ShowListOfFiles.aspx" and sends the file in the OnLoad Eventhandler. The filename to download is stored in a Session variable....
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
3
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
4
by: Chris | last post by:
Hi Everyone, I am using a regex to check for a string. When all the file contains is my test string the regex returns a match, but when I embed the test string in the middle of a text file a...
6
by: Michael | last post by:
I need to copy a huge file (around 300Mb) from a mapped network drive to another. I have created a console application and used System.IO.File.Copy function. But I want to know the process of...
1
ddtpmyra
by: ddtpmyra | last post by:
When Im downloading a file from mysql database the file is already corrupted below are the code I used on downloading to mysql and uploading from mysql. PDF file are doing okay as long as it is a...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
4
by: maheswaran | last post by:
HI All, I have problem in files downloading over ssl. When am trying with IE Browser i got "Internet Explorer cannot download 40 from blah.gov Internet Explorer was not able to open this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.