【问题标题】:How to get size of uploaded file in IE8,9 using Javascript or jQuery?如何使用 Javascript 或 jQuery 在 IE8,9 中获取上传文件的大小?
【发布时间】:2012-07-31 08:03:38
【问题描述】:

我尝试了很多,但没有找到任何方法来解决我的问题。

如何在 IE8,9 中获取上传文件的大小?

【问题讨论】:

标签: jquery


【解决方案1】:

您需要使用 Active X,因为这些版本的 IE 不支持 HTML5 File API。我在网上找到了一个代码 sn-p 可以做到这一点。

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");
}

详情请参阅this。 另请查看 IE 的 API 参考中的备注部分,用于 |input type=file| here.

【讨论】:

    猜你喜欢
    • 2012-05-31
    • 2010-12-09
    • 2018-09-24
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    • 1970-01-01
    相关资源
    最近更新 更多