Onkar Janwa
Onkar Janwa

Reputation: 3950

How to get size of uploaded file in IE8,9 using Javascript or jQuery?

I have tried a lot but did not find any way to solve my problem.

How to get size of uploaded file in IE8,9 ?

Upvotes: 4

Views: 7589

Answers (1)

Abhishek Potnis
Abhishek Potnis

Reputation: 897

You will need to use Active X as those versions of IE do not support the HTML5 File API. I found a code snippet on the web that does that.

function getSize()
{
    var myFSO = new ActiveXObject("Scripting.FileSystemObject");
    var filepath = document.upload.file.value;
    var thefile = myFSO.getFile(filepath);
    var size = thefile.size;
    alert(size + " bytes");
}

Refer this for details. Also take a look at the Remarks Section in the API Reference of IE for |input type=file| here.

Upvotes: 2

Related Questions