Is there any other way to get client-side file size without using ActiveX
in IE
?
I get the file size on the client side, but IE opens a security notification popup for ActiveX controls. Is there any other way to get the file size or hide the ActiveX popup?
Here is the code to get the file size on the client side.
<html> <body> <form id="file"> <input type="file" id="loadfile" /> <input type="button" value="Image Size" onclick="testSize()" /> </form> <script type="text/javascript"> function testSize(){ var browserInfo = navigator.userAgent.toLowerCase(); if(browserInfo.indexOf("msie") > -1){ var filepath = document.getElementById('loadfile').value; alert(filepath + " Test "); var myFSO = new ActiveXObject("Scripting.FileSystemObject"); var thefile = myFSO.getFile(filepath); var imgbytes = thefile.size; alert( "name " + thefile.name + "Size " + thefile.size ); }else{ var file = document.getElementById('loadfile').files[0]; alert( "name " + file.name + "Size " + file.size ); } } </script> </body> </html>
Thanks in advance.
source share