IE浏览器下读取客户端上传的文件大小
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <title>文件大小判断</title> 6 </head> 7 <body> 8 限制:<input type="text" size="4" value="10" name="fileSizeLimit" id="fileSizeLimit"/> K 9 <input type="file" name="file1" id="file1" size="40" onchange="changeSrc(this)"/> 10 <br> 11 <img id="fileChecker" /> 12 13 <script type="text/javascript"> 14 var oFileChecker = document.getElementById("fileChecker"); 15 16 function changeSrc(filePicker) 17 { 18 oFileChecker.src = filePicker.value; 19 } 20 21 oFileChecker.onreadystatechange = function () 22 { 23 if (oFileChecker.readyState == "complete") 24 { 25 checkSize(); 26 } 27 } 28 29 function checkSize() 30 { 31 var limit = document.getElementById("fileSizeLimit").value * 1024; 32 33 if (oFileChecker.fileSize > limit) 34 { 35 alert("文件大小超出限制!"); 36 } 37 else 38 { 39 alert("文件大小符合要求."); 40 } 41 } 42 </script> 43 </body> 44 </html>
李小家