Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.TotalBytes and Request.BinaryRead

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
I'm trying to check the total bytes of a submittal and have ASP react differently if the bytes exceed a certain amount. Here is a small sample that has generated the same error both on my web server running IIS 5.0 and my personal computer at home running PWS.

Submittal Page (submitfile.asp)
Code:
<html>
<head>
<title>Submit File To Server</title>
<body>
<form name=&quot;form1&quot; action=&quot;receivefile.asp&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
<input type=&quot;file&quot; size=&quot;25&quot; name=&quot;file1&quot;><br>
<input type=&quot;submit&quot; value=&quot;Test&quot;>
</form>
</body>
</html>

Page that receives request (receivefile.asp)
Code:
<%@ Language=&quot;VBScript&quot; %>
<% Option Explicit %>
<%
Response.Write Request.TotalBytes
%>

When I select a small file (200K or less) then receivefile.asp responds with the total bytes sent. In this case, for a 200K file the response is about 201500 because the totalbytes includes the form data as well. When I select a larger file (say 500K) then here are the errors I am receiving.

Netscape 4.72 AND IE 5.0 running IIS 5.0
Code:
HTML Error &quot;Cannot locate server, DNS not found&quot;


Netscape 4.5 running PWS
Code:
Alert Window
A network error ocurred while Netscape was sending data. 
Network Error: Invalid Argument
Try connecting again.
OK Button

IE 4.0 running PWS
Code:
No error, but the operation is expensive.

If the receivefile.asp is written as follows, everything works fine.
Code:
<%@ Language=&quot;VBScript&quot; %>
<% Option Explicit %>
<%
dim memvar
memvar = Request.BinaryRead(Request.TotalBytes)
Response.Write Request.TotalBytes
%>
However, this also is an expensive operation. My original thinking was that the single Request.TotalBytes command was not expensive. But I'm thinking again since I couldn't produce the error at home running IE 4.0 and PWS but the Request.TotalBytes command took about 10 seconds on a 700K file. I thought that it was the Request.BinaryRead command that was the expensive part. Does ASP need to receive the entire chunk of data before it can return a Request.TotalBytes figure ?? Is there a less expensive way to find out how much data the client is attempting to submit?? I have a test account on xdrive.com and attempted to upload a 129MB file to my virtual drive. Although the upload was very time consuming, the upload status window that they provide tells me the file size in less than a second. If the cgi can determine the total size of the submittal that quickly, then I'm sure it can redirect appropriately. Just trying to prevent users from uploading huge files into my web server.

Any help would save me a great deal of time and headache!!

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top