Get the file size in IE before downloading. Gmail does it - how?

I have a file upload form. I would like to check the file size before actually downloading the file. I can do it in Chrome, but how do I get it to work in IE?

Please note that this is possible for gmail. When I drag the file to the file attachment area, it immediately tells me the file size. I tried this in IE9 and IE8. It can also tell me the file size, even if I’m disconnected from the Internet, so I don’t like to download the file first. I did not (as far as I recall) had to provide any special ActiveX permissions or anything else.

I saw below in other answers, but this requires special permission from the user, right? I would like to avoid this. Also, I'm not sure how to actually get the file that I need for this.

var oas = new ActiveXObject("Scripting.FileSystemObject"); var e = oas.getFile(file.value); 
+4
source share
2 answers

Google does this with backup.

If there is no html5 api file, it uses adobe flash to download files.

you can use something like this to get crossbrowser compatibility: https://github.com/valums/file-uploader

+2
source

If you want to use ActiveXObject , the correct code is:

 var fso = new ActiveXObject("Scripting.FileSystemObject"), file = fso.GetFile(file_path), size = file.size; 
0
source

All Articles