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

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 comment