views:

1296

answers:

3

Client side validation is important to improve usability.

Is there any cross-browser way to validate the file size before uploading it to the server. I am using asp.net file upload control.

I found some third-party controls do that check:

http://ajaxuploader.com/Demo/simple-upload.aspx

and

http://demo.essentialobjects.com/Default.aspx?path=AJAXU

but How?

+2  A: 

Not possible I am afraid unless you use a flash uploader like swfupload.

redsquare
I found some third-party controls do that check http://ajaxuploader.com/Demo/simple-upload.aspxandhttp://demo.essentialobjects.com/Default.aspx?path=AJAXUploader
Khaled Musaied
They use flash:) look at the js. They embed swf files
redsquare
+2  A: 

The only way to 'know' the filesize before it is sent over to the server is to have a 'thicker than javascript' client-side plugins/add-ons. These will have to be installed on the client system. E.g. using SWFUpload, Java applets, ActiveX controls.

o.k.w
looks like a copy of my answer!
redsquare
@redsquare, I added your "swfupload" as one of the examples. A +1 for that. :-)
o.k.w
@o.k.w can you post a sample code?
Khaled Musaied
A: 

Why? A decent webserver will return a 410 the moment it got a content length header larger than expected.

zepolen
I don't want to wait till the server shows me an error page.
Khaled Musaied
if you need to add a question add it as a comment on the main question
Khaled Musaied
I did not have enough karma at that point to make a comment.You will only wait 200msec or so, is that such a big deal?
zepolen