How to get file size for IE browser using javascript or Jquery?

I have used ActiveXObject for IE browser but it is not working. I have got the file size for other browsers in js but unable to getting the file size for IE browser. I have used the following code for this:-

if ($.browser.msie==true)
 {
     var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
     var path = document.uploadDocumentForm.documentUpload.value;
     var file = fileSystemObject.getFile(path);
     var size = file.size;
     alert(size);

/*  var a = document.getElementById(fileId).value;
            $('#myImage').attr('src',a);
            var imgbytes = document.getElementById('myImage').fileSize;       
            alert("here"+imgbytes);
            var imgkbytes = Math.round(parseInt(imgbytes)/1024);        */

}
else
{
               var fileInput = $("#"+fileId)[0]; 
               var imgbytes = fileInput.files[0].size; 
              var imgkbytes = Math.round(parseInt(imgbytes)/(1024));
}   

Can anyone help me to get the filesize for IE browsers. I have gone through all the ideas but unable to get filesize for IE browser. Please provide the idea or code for this…

  • Is it possible to upload an image in an offline web application?
  • How do I use Plupload with Node.js and show the percentages of upload?
  • FormData is empty when using jQuery ajax()
  • triggering file input within an iframe in Chrome with javascript
  • Send drag and drop file to input type file element
  • Check file size before upload
  • Set data.formData for each chunk
  • Queuing asynchronous HTTP file uploads
  • How reload jsf page after primefaces upload?
  • How to create an AJAX request with JavaScript that contains both file and post data
  • Check file size before upload
  • Maximum number of files being uploaded by input type file
  • One Solution collect form web for “How to get file size for IE browser using javascript or Jquery?”

    A suggestion that works is following.

    <script type="text/javascript">
    function AlertFilesize(){
        if(window.ActiveXObject){
            var fso = new ActiveXObject("Scripting.FileSystemObject");
            var filepath = document.getElementById('fileInput').value;
            var thefile = fso.getFile(filepath);
            var sizeinbytes = thefile.size;
        }else{
            var sizeinbytes = document.getElementById('fileInput').files[0].size;
        }
    
        var fSExt = new Array('Bytes', 'KB', 'MB', 'GB');
        fSize = sizeinbytes; i=0;while(fSize>900){fSize/=1024;i++;}
    
        alert((Math.round(fSize*100)/100)+' '+fSExt[i]);
    }
    </script>
    
    <input id="fileInput" type="file" onchange="AlertFilesize();" />
    

    It was taken from another answer Get file size before uploading .