Posted on 2009-12-29 08:48
landor 阅读(1188)
评论(1) 编辑 收藏 所属分类:
javascript
<html>
<head>
<script type="text/javascript">
var Sys = {};
if(navigator.userAgent.indexOf("MSIE")>0) {
Sys.ie=true;
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
Sys.firefox=true;
}
function checkFileChange(obj) {
var filesize = 0;
if(Sys.firefox){
filesize = obj.files[0].fileSize;
}else if(Sys.ie){
var filePath = obj.value;
var image=new Image();
image.dynsrc=filePath;
filesize=image.fileSize;
}
alert(filesize);
}
</script>
</head>
<body>
<input type="file" id="myId" name="myId">
<input type="button" value="判断文件大小" onclick="checkFileChange(document.getElementById('myId'))">
</body>
</html>