How to check the file upload size at client side using java script

 

Guys, I found this amazing this which i never knew. You can check the file size at client side only, before user submits the page. this will save user time and of course the processing power at server.

Below code demonstrate how you can do it…

<html>
<head>
<script type="text/javascript">
A() {
var oas = new ActiveXObject("Scripting.FileSystemObject"); var d = document.a.b.value; var e = oas.getFile(d); var f = e.size; alert(f + " bytes"); }
</script>
</head>

<body>
    <form name="a">
    <input type="file" name="b">
    <input type="button" name="c" value="SIZE" onclick="A();">
    </form>
</body>
</html>

The above code is only applicable in internet explore.

i will be publishing the code for other browsers soon.

Tarun Juneja

Advertisements

2 thoughts on “How to check the file upload size at client side using java script

    • Thats not true Spamme!
      if others can not implement a good thing, you must not blame MS.
      MS just proven that it is possible and worst part is that no one else can implement it.
      MS rocks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s