- <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;" onchange="fileChange(this);"/>
- </body>
- </html>
js判断上传文件大小
最新推荐文章于 2021-08-06 10:45:42 发布