update Upload

update Upload
This commit is contained in:
梁灏 2017-01-22 17:19:37 +08:00
parent bc3bcb098b
commit a6ac0a7603
3 changed files with 133 additions and 64 deletions

View file

@ -202,6 +202,24 @@
}
},
post (file) {
// check format
if (this.format.length) {
const _file_format = file.name.split('.').pop().toLocaleLowerCase();
const checked = this.format.some(item => item.toLocaleLowerCase() === _file_format);
if (!checked) {
this.onFormatError(file);
return false;
}
}
// check maxSize
if (this.maxSize) {
if (file.size > this.maxSize * 1024) {
this.onExceededSize(file);
return false;
}
}
this.handleStart(file);
let formData = new FormData();
formData.append(this.name, file);
@ -235,24 +253,6 @@
showProgress: true
};
// check format
if (this.format.length) {
const _file_format = _file.name.split('.').pop().toLocaleLowerCase();
const checked = this.format.some(item => item.toLocaleLowerCase() === _file_format);
if (checked) {
this.onFormatError(file);
return;
}
}
// check maxSize
if (this.maxSize) {
if (_file.size > this.maxSize * 1024) {
this.onExceededSize(file);
return;
}
}
this.fileList.push(_file);
},
getFile (file) {