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!

Checking Uploaded File Size in ASP Before Executing The Upload.

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
I am struggling on validating file size "BEFORE" executing the file upload process. I'm currently validating the Request.TotalBytes property then redirecting to an error page if that exceeds a specific amount. However, I have found that if I do that before the Request.BinaryRead method, Internet Explorer gives me an error that is typical of trying to access It's not a "Page cannot be found" error. It's almost as if the web server completely disconnects from the client and only does it when trying to upload large files (Which of course is the whole reason for the validation). When I back click from the error page, session state is maintained and everything is back to normal. If I place the validation code after the Request.BinaryRead method, everything works fine. However, the Request.BinaryRead method seems to task the server quite heavily on large files. While testing the validation on a 10/100MB LAN I watched the web server console during the Request.BinaryRead method. The network adapter was quiet but the processors were going nuts. Without being able to validate file size before executing the Request.BinaryRead method, how can I prevent someone from attempting to upload a 100MB file which would eventually timeout the script but would task the server during that time. I have an account at xdrive.com and attempted to upload a 129MB file and within just a few seconds, the upload status screen told me how large the file was. How do they do that ?? Any help would be greatly appreciated.
 
I'm no expert - perhaps this will not be helpful at all....Could it not be that in the case of the xdive.com, that they are using client side scripting to establish the file size before even attempting the upload? If that is the case, could you not also use client side scripting to establish file sizes, thereby validating the upload before it commences?

If this reply is useless, I apologise for wating your time :)
 
Client Side Scripting would be great !! However, for security reasons, in order to gain access to the file system object on someone elses computer requires ActiveX or signed scripts. In either case, you have to bother the user to accept trust or download an ActiveX. None of which I want to do. If you hear of a simpler way to client side script this thing, please let me know. My basic hurdle is trying to find out why, when I submit a page to the server using enctype=&quot;multipart/form-data&quot; as a form property that my server wigs out if I don't perform a Request.BinaryRead(Request.TotalBytes) command. I can't even submit the page to another page with just one simple line that says <%=Hello!%> If I remove the enctype=&quot;multipart/form-data&quot; property from the form, it works fine. Of course, without that I can't use the form to upload files. Anyone ?? Help ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top