473,387 Members | 1,583 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,387 software developers and data experts.

Limiting Uploaded File Size

I understand that setting maxRequestLength in Web.config will allow me to
limit the size of file users upload to an ASP.NET Web site.

Questions:
1. What happens when the user attempts to upload a file that is larger than
the max that I specify via maxRequestLength? Is there some exception I can
handle and then have some nice way to tell the user what happened?

2. Even better - is there any reasonably easy way to determine the file size
*before* the file is uploaded (i.e., check the size to determine if the file
should even be sent)?

Thanks!
Nov 19 '05 #1
4 1594
If the file is too large, an ugly error screen will be displayed to the user
and there's nothing you can do about this without some kind of thick client.

So to solve your problem, you might look into using a 3rd party activex
control such as this:
http://fileup.softartisans.com/fileup-231.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Johnson" <JM**@SpamThis.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I understand that setting maxRequestLength in Web.config will allow me to
limit the size of file users upload to an ASP.NET Web site.

Questions:
1. What happens when the user attempts to upload a file that is larger
than the max that I specify via maxRequestLength? Is there some exception
I can handle and then have some nice way to tell the user what happened?

2. Even better - is there any reasonably easy way to determine the file
size *before* the file is uploaded (i.e., check the size to determine if
the file should even be sent)?

Thanks!

Nov 19 '05 #2
"Johnson" <JM**@SpamThis.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP15.phx.gbl ¤¤¼¶¼g...
I understand that setting maxRequestLength in Web.config will allow me to
limit the size of file users upload to an ASP.NET Web site.

Questions:
1. What happens when the user attempts to upload a file that is larger than the max that I specify via maxRequestLength? Is there some exception I can
handle and then have some nice way to tell the user what happened? Yes. There is exception that you can handle. But since browsers do not
accept response stream when this type of error occurs (That's why you see
the "server is not responding or DNS error" screen), there's little you can
do to tell the user what happens. The best you can do without extra
component will be to send an email to the user telling he/she about this.
The other option is, as Steve said, use one of the 3rd party solutions.
(Thick client is not a must in this case, I've found a way to work around
with a component using extra progress bar window, casing the upload page
being redirected to error page when the error happens, so not extra plugin
is required on the clients)
2. Even better - is there any reasonably easy way to determine the file size *before* the file is uploaded (i.e., check the size to determine if the file should even be sent)?

You must use thick clients then. Both javascript and vbscript do not expose
method to check that.
Nov 19 '05 #3
>> I've found a way to work around with a component using
extra progress bar window, casing the upload page
being redirected to error page when the error happens, so
not extra pluginis required on the clients

Can you please post this code? I'd love to see how it works.

--
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

Nov 19 '05 #4
That's nothing trickly.

The basic idea is that, when the upload is cancelled/finished, the uploadid
will not be able to be found in the upload component. So in that case I just
check to see if the main window goes to the "upload finish" page if the
upload is not found. If it's true, the main window is redirected to the
error page.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP15.phx.gbl ¤¤¼¶¼g...
I've found a way to work around with a component using
extra progress bar window, casing the upload page
being redirected to error page when the error happens, so
not extra pluginis required on the clients

Can you please post this code? I'd love to see how it works.

--
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

Nov 19 '05 #5

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

Similar topics

3
by: lawrence | last post by:
I've two scripts, one to upload images, another to delete them. The upload script works fine, but the delete script has permissions trouble. How can PHP not have permission to delete an image it...
3
by: siliconmike | last post by:
>From my various readings I figured that there is no reliable way to check file size before upload begins via a POST method. Browser side checking can be fooled. I also figured that file size is...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
4
by: RedHair | last post by:
I'd like to set up a file system for the ASP.NET 2.0 application to store user-uploaded files, since the members are more than 100,000 people, the basic requirements are as below: (1) The file...
4
by: lawrence k | last post by:
I've a file that starts like this: <form id="pdsForm" method="post" action="/mcControlPanel.php" class="mcForm" charset="UTF-8" enctype="multipart/form-data" > and it contains this input: ...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
10
by: jonathan184 | last post by:
Hi I am tryin to validate certian types of files to be uploaded and file size and if this follows this correctly then insert in db this is the code i did so far. So far I commented out the parts...
2
by: Mufasa | last post by:
I am using the file upload control and want to limit the size of the file that is uploaded. But it appears as if it actually uploads the file and then does the check. Is that true? Ideally I'd...
7
by: sandeepk84 | last post by:
Hi all... I have file upload option in my web application. I use Struts 2. I wanted to show a preview of the uploaded file to the user. The uploaded file can be of any type like...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.