javascript - How to preview locally and determine the file size of locally uploaded pdf files (compatible with IE9 browser)
ringa_lee
ringa_lee 2017-07-05 10:40:29
0
1
1031

How to preview locally uploaded pdf files and determine the file size (compatible with ie9 browser)

ringa_lee
ringa_lee

ringa_lee

reply all(1)
黄舟
//文件大小可以根据此方法判断,兼容ie8,ie9,ie9以上也支持 
function getFileSize(obj){ 
   try{
        var file = obj;
        file.select(); 
        file.blur(); 
        var path = document.selection.createRange().text; 
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        fileSize = fso.GetFile(path).size; 
        alert(fileSize);//弹出文件大小
     }catch(e){ 
       alert(e+"\n"+"如果错误为:Error:Automation 服务器不能创建对象;"+"\n"+"请按以下方法配置浏览器:"+"\n"+"请打开【Internet选项-安全-Internet-自定义级别-ActiveX控件和插件-对未标记为可安全执行脚本的ActiveX控件初始化并执行脚本(不安全)-点击启用-确定】");
        return window.location.reload(); 
   }}
  转载链接:http://www.imooc.com/article/9593
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template