如何使用Javascript或jQuery获取IE8,9中上传文件的大小? [英] How to get size of uploaded file in IE8,9 using Javascript or jQuery?
本文介绍了如何使用Javascript或jQuery获取IE8,9中上传文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试了很多,但是没有找到解决问题的方法.
I have tried a lot but did not find any way to solve my problem.
如何在IE8,9中获取上传文件的大小?
How to get size of uploaded file in IE8,9 ?
推荐答案
您将需要使用Active X,因为那些版本的IE不支持HTML5 File API.我在网上找到了一个可以实现此目的的代码段.
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");
}
请参考此有关详细信息. 另请查看IE的API参考中输入类型=文件|"的备注"部分. 此处.
Refer this for details. Also take a look at the Remarks Section in the API Reference of IE for |input type=file| here.
这篇关于如何使用Javascript或jQuery获取IE8,9中上传文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文