标签:上传文件大小判断
代码如下:上传:<input type="file" style="width: 500px;" onchange="fileChange(this);"/> <script type="text/javascript"> function fileChange(target){ var isIE = /msie/i.test(navigator.userAgent) && !window.opera;//兼容IE6以上的版本 var fileSize = 0; var fileName = null; if(isIE && !target.files){ var filePath = target.value; var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); var file = fileSystem.GetFile(filePath); fileName = file.Name; fileSize = file.Size; }else{ fileSize = target.files[0].size; fileName = target.files[0].name; } var size = fileSize / 1024 / 1024; alert('fileSize:'+fileSize+'M'); alert('fileName:'+fileName); } $(document).ready(function(){ }); </script>
标签:上传文件大小判断
原文地址:http://blog.csdn.net/pleasurehappy/article/details/45879635