/** * * @param obj file对象 document.getElementById(elementId); * @returns */function getExcelFileFullPath(obj){ if (obj){ // ie if (window.navigator.userAgent.indexOf("MSIE") >= 1){ obj.select(); return document.selection.createRange().text; }else{// firefox 等其他标准W3c if (obj.files){ return obj.files.item(0).getAsDataURL(); } return obj.value; } }else{ return ""; }}/** * * @param 比较文件大小 * @returns */function getFileSize(elementId){ var agent = window.navigator.userAgent; var fileupload = document.getElementById(elementId); var isIE6 = agent.indexOf('MSIE 6.0') != -1; var isIE = agent.indexOf('MSIE') != -1; // var maxSize = 2000000; var fileSize = 0; try{ if(isIE6){//ie6 filepath = fileupload.value; var aa = new ActiveXObject("Scripting.FileSystemObject"); fileSize = aa.GetFile(filepath).size; }else if(isIE){//其他ie fileupload.select(); filepath = document.selection.createRange().text; var aa = new ActiveXObject("Scripting.FileSystemObject"); fileSize = aa.GetFile(filepath).size; }else{//姑且w3c标准 fileSize = fileupload.files[0].size; } return fileSize; }catch(e){ alert("请修改IE浏览器ActiveX安全设置为启用~!"); return fileSize; } return fileSize; }
2.ieTest<input type="file">不正常显示
这个很无奈。听人说是Bug,哈哈哈。
参考些网站:1.
2.http://www.2cto.com/os/201107/96746.html