<HTML> <HEAD> <SCRIPT> function getFileSize (fileName) { window.oldOnError = window.onerror; window.onerror = function (err) { if (err.indexOf('utomation') != -1) { alert('file access not possible'); return true; } else return false; }; var fso = new ActiveXObject('Scripting.FileSystemObject'); var file = fso.GetFile(fileName); window.onerror = window.oldOnError; return file.Size; } function showImageDimensions () { alert(this.width + 'x' + this.height); } </SCRIPT> </HEAD> <BODY> <FORM NAME="formName"> <INPUT TYPE="file" NAME="fileName"> <BR> <INPUT TYPE="button" VALUE="检查文件大小" ONCLICK="alert(getFileSize(this.form.fileName.value))"> </FORM> </BODY> </HTML> |
使用javasctipt查看被选择图片大小
最新推荐文章于 2024-08-22 16:43:17 发布