<html>
<head>
<script type="text/javascript">
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
function fileChange(target) {
var fileSize = 0;
if (isIE && !target.files) {
var filePath = target.value;
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
var file = fileSystem.GetFile (filePath);
fileSize = file.Size;
} else {
fileSize = target.files[0].size;
}
var size = fileSize / 1024;
if(size>10000){
alert("附件不能大于10M");
}
}
</script>
</head>
<body>
<input type="file" name="contractFileName" style="width: 500px;" οnchange="fileChange(this);"/>
</body>
</html>
js控制上传文件的大小
最新推荐文章于 2019-09-25 17:15:48 发布