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>   

此代码不起作用,我单击大小按钮没有发生任何事情我检查了 ActiveXObject 不起作用我正在使用 IE 这是什么原因

4

1 回答 1

0

而不是使用ActiveXObjecttry this withjQuery

对于下面的 HTML

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

尝试以下操作:

//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);

});

请参阅以下线程:

如何使用 jQuery 检查文件输入大小?

于 2013-08-29T10:28:44.970 回答