Skip to content

Commit

Permalink
修复 upload size 提示错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sentsin committed May 6, 2018
1 parent f12f08e commit c9f80d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
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"
Expand Down
5 changes: 1 addition & 4 deletions src/lay/modules/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c9f80d7

Please sign in to comment.