Willian
Willian

Reputation: 95

Validate file size before upload - IE8+

I want to validate the file size before upload on IE8+

I tried

Validate File size before upload

But didn't work.

And I can't configure every IE browser to use the "ActiveXObject" (I saw that is one way for the solution).

What I should do?

Upvotes: 3

Views: 865

Answers (2)

Karl Anderson
Karl Anderson

Reputation: 34846

Using the ASP.NET FileUpload control you cannot use code to validate the size of a file and inform the user.

If you want a better user experience, then I suggest you investigate some open source solutions like the following:

  1. Custom HTTP module

    NeatUpload is a free option.

  2. Silverlight/Flash option

    SWFUpload is a free option.

  3. Asynchronous chunking option

    RadAsyncUpload - Telerik's ASP.NET AsyncUpload is a pay option, check website for pricing.

Upvotes: 1

r.vengadesh
r.vengadesh

Reputation: 1837

Try this

<form enctype="multipart/form-data">
   <label for="file">Filename:</label>
   <input type="file" name="file" id="myFile"><br>
</form>


<script>
$('#myFile').bind('change', function() {
alert(this.files[0].size);
});
</script>

Upvotes: 0

Related Questions