0

javascript snippet to find the file size in internet explorer, the only i found was ActiveX object, but unfortunately it doesn't work in IE 9. error is mentioned below.

var iefilePath = $("fileInput").val();
var ieFileName = iefilePath.slice(iefilePath.lastIndexOf("\\") + 1);
var objFSO = new ActiveXObject("Scripting.FileSystemObject"); 
//error SCRIPT429: Automation server can't create object
var objFile = objFSO.getFile(iefilePath);
var fileSize = objFile.size;
alert(objFile.size);

Below image shows that, ActiveX is supported in IE9. enter image description here

Prasob
  • 1,963
  • 2
  • 11
  • 20
  • IIRC ActiveX is the only way to do this in IE9, however ActiveX is disabled by default so you'll need to guide your users to enable it, or find a polyfill. Also, you still need IE9 support? Have mercy on your soul... – Rory McCrossan Feb 01 '18 at 10:32
  • it's a huge application, most of the user still uses IE9 according to our reports. ;) – Prasob Feb 01 '18 at 10:33
  • You could try checking if ActiveX is enabled first :https://stackoverflow.com/questions/4313438/how-do-i-detect-if-activex-is-enabled-in-the-browser-of-client – Rory McCrossan Feb 01 '18 at 10:35
  • That is secondary, when i try with IE 9/IE8, as per MS document it should work. – Prasob Feb 01 '18 at 10:39
  • Anyway, IE9 have the support for ActiveX, Please check the image attached. – Prasob Feb 01 '18 at 10:45

0 Answers0