1

Im using a fileupload control for my asp application and it throws a HttpException when the file upload size is bigger than the max request length.

As far i understand the fileupload will open a memory stream to a file once the file browse dialog is closed but there is no way of knowing when the dialog is closed so that I can make a decision whether to abort the upload.

Does anyone know of a way of examining the file size before the upload begins?

Spam.

3 Answers 3

1

If you leave file upload to built-in Asp.Net mechanisms, then an upload will fail if the request size is larger than the max size set in web.config (or machine.config).

You can solve that by writing your own HttpHandler and first check the size of the request, and then handle the request data in your code.

Sign up to request clarification or add additional context in comments.

Comments

0

This control will let you upload any file size. I use it and it is very very handy. I believe the source is there if you want it.

http://www.brettle.com/neatupload

Comments

0

I doubt there is a universal way to check file size on client-side ( I mean for all browsers ), as usually client-side script does not have access to file system.

I used to catch the exception on server side and then notice the user when programming in classic ASP.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.