diff --git a/examples/upload.html b/examples/upload.html index e37161e4..673eba4e 100644 --- a/examples/upload.html +++ b/examples/upload.html @@ -89,7 +89,7 @@ layui.use('upload', function(){ var uploadInst = upload.render({ elem: '#test1' ,url: '/upload/' - //,size: 60 //限制文件大小,单位 KB + ,size: 2000 //限制文件大小,单位 KB ,accept: 'file' ,fileAccept: 'image/*' ,exts: "jpg|png|gif|bmp|jpeg|pdf" diff --git a/src/lay/modules/upload.js b/src/lay/modules/upload.js index 6026fcd4..b178ee8a 100644 --- a/src/lay/modules/upload.js +++ b/src/lay/modules/upload.js @@ -381,12 +381,9 @@ layui.define('layer' , function(exports){ layui.each(that.chooseFiles, function(index, file){ if(file.size > 1024*options.size){ var size = options.size/1024; - size = size >= 1 - ? (Math.floor(size) + (size%1 > 0 ? size.toFixed(1) : 0)) + 'MB' - : options.size + 'KB' + size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB' elemFile.value = ''; limitSize = size; - } }); if(limitSize) return that.msg('文件不能超过'+ limitSize);