mirror of https://github.com/layui/layui
修复 多上传设置文件大小限制时,删除超出大小的文件仍然校验不通过的问题
parent
a60241976e
commit
c38e6d39bc
|
@ -171,17 +171,23 @@ layui.define(['lay','layer'], function(exports){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//执行上传
|
// 执行上传
|
||||||
Class.prototype.upload = function(files, type){
|
Class.prototype.upload = function(files, type){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config
|
var options = that.config;
|
||||||
,elemFile = that.elemFile[0]
|
var elemFile = that.elemFile[0];
|
||||||
|
|
||||||
|
// 获取文件队列
|
||||||
|
var getFiles = function(){
|
||||||
|
return files || that.files || that.chooseFiles || elemFile.files;
|
||||||
|
};
|
||||||
|
|
||||||
//高级浏览器处理方式,支持跨域
|
//高级浏览器处理方式,支持跨域
|
||||||
,ajaxSend = function(){
|
var ajaxSend = function(){
|
||||||
var successful = 0, failed = 0
|
var successful = 0;
|
||||||
,items = files || that.files || that.chooseFiles || elemFile.files
|
var failed = 0
|
||||||
,allDone = function(){ //多文件全部上传完毕的回调
|
var items = getFiles();
|
||||||
|
var allDone = function(){ // 多文件全部上传完毕的回调
|
||||||
if(options.multiple && successful + failed === that.fileLength){
|
if(options.multiple && successful + failed === that.fileLength){
|
||||||
typeof options.allDone === 'function' && options.allDone({
|
typeof options.allDone === 'function' && options.allDone({
|
||||||
total: that.fileLength
|
total: that.fileLength
|
||||||
|
@ -412,8 +418,8 @@ layui.define(['lay','layer'], function(exports){
|
||||||
|
|
||||||
//检验文件数量
|
//检验文件数量
|
||||||
that.fileLength = function(){
|
that.fileLength = function(){
|
||||||
var length = 0
|
var length = 0;
|
||||||
,items = files || that.files || that.chooseFiles || elemFile.files;
|
var items = getFiles();
|
||||||
layui.each(items, function(){
|
layui.each(items, function(){
|
||||||
length++;
|
length++;
|
||||||
});
|
});
|
||||||
|
@ -427,11 +433,11 @@ layui.define(['lay','layer'], function(exports){
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//检验文件大小
|
// 检验文件大小
|
||||||
if(options.size > 0 && !(device.ie && device.ie < 10)){
|
if(options.size > 0 && !(device.ie && device.ie < 10)){
|
||||||
var limitSize;
|
var limitSize;
|
||||||
|
|
||||||
layui.each(that.chooseFiles, function(index, file){
|
layui.each(getFiles(), function(index, file){
|
||||||
if(file.size > 1024*options.size){
|
if(file.size > 1024*options.size){
|
||||||
var size = options.size/1024;
|
var size = options.size/1024;
|
||||||
size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB'
|
size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB'
|
||||||
|
|
Loading…
Reference in New Issue