日期:2014-05-16 浏览次数:20321 次
<HTML><HEAD> <SCRIPT> function getFileSize (fileName) { if (document.all) { window.oldOnError = window.onerror; window.onerror = function (err) { if (err.indexOf('utomation') != -1) { alert('没有访问文件的权限'); return true; } else return false; }; var fso = new ActiveXObject('Scripting.FileSystemObject'); var file = fso.GetFile(fileName); window.onerror = window.oldOnError; return file.Size; }} </SCRIPT> </HEAD> <BODY> <FORM NAME="formName"><INPUT TYPE="file" NAME="fileName"><BR> <INPUT TYPE="button" VALUE="查看文件字节大小" ONCLICK="alert(getFileSize(this.form.fileName.value))"><BR> </FORM></BODY> </HTML>
?http://heisetoufa.iteye.com/blog/227809
?
第二种方法:
<script type="text/javascript"> function getFileSize(filePath) { var image=new Image(); image.dynsrc=filePath; alert(image.fileSize); } </script>
?