[英]How to check filesize in IE 5 without activeX object in Javascript?
<script>
function GetFileSize() {
var fi = document.getElementById('file'); // GET THE FILE INPUT.
// VALIDATE OR CHECK IF ANY FILE IS SELECTED.
if (fi.files.length > 0) {
// RUN A LOOP TO CHECK EACH SELECTED FILE.
for (var i = 0; i <= fi.files.length - 1; i++) {
var fsize = fi.files.item(i).size; // THE SIZE OF THE FILE.
document.getElementById('fp').innerHTML =
document.getElementById('fp').innerHTML + '<br /> ' +
'<b>' + Math.round((fsize / 1024)) + '</b> KB';
}
}
}
Getting exception "Unable to get property 'length' of undefined or null reference" in fi.files.length 在fi.files.length中获取异常“无法获取未定义或空引用的属性'length'”
You can't. 你不能
IE 5 predates any native browser features for interacting with local files. IE 5早于任何与本地文件交互的本机浏览器功能。
Note also that IE 5 hasn't been supported on Windows since Windows NT which hasn't had a security update in 18 years. 还请注意,自Windows NT以来18年来一直没有安全更新的Windows NT以来不支持IE 5。
Do not use IE 5 不要使用IE 5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.