0
<html>
    <head>   
        <script>   
            function 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>   

this code is not working, i click the size button nothing is happen i checked ActiveXObject is not working i am using IE what is the reason for this

Mohammad Faisal
  • 5,783
  • 15
  • 70
  • 117
sasi
  • 13
  • 2
  • 5
  • Please make things easier for people reading your question and **format your code**. – Oded Mar 31 '11 at 11:26
  • 1
    Most likely it does not work because you do not have access to the actual filename anymore in a file upload field. On a normal web page you will not be allowed to do this anyway. Perhaps Flash can help you. You should have continued reading http://forums.digitalpoint.com/showthread.php?t=6704 – mplungjan Mar 31 '11 at 11:31

1 Answers1

0

Instead of using ActiveXObject try this with jQuery

For the HTML bellow

<input type="file" id="myFile" />

try the following:

//binds to onchange event of your input field
$('#myFile').bind('change', function() {

  //this.files[0].size gets the size of your file.
  alert(this.files[0].size);

});

See following thread:

How to check file input size with jQuery?

Community
  • 1
  • 1
Mohammad Faisal
  • 5,783
  • 15
  • 70
  • 117