fix: when batch uploading, filter out unaccept files

This commit is contained in:
chenos 2021-04-22 19:01:28 +08:00
parent a19311cb24
commit 3268267ccd

View File

@ -197,11 +197,14 @@ export const Upload = connect({
onChange({ fileList, file, ...others }) {
// console.log({fileList, file, others});
if (accept && !attrAccept(file, accept)) {
message.error('不支持上传当前格式的文件');
message.error(`${file.name}」不支持上传的文件格式`);
return;
}
setFileList(fileList);
const list = toValues(fileList);
const fList = fileList.filter(file => {
return attrAccept(file, accept);
});
setFileList(fList);
const list = toValues(fList);
onChange(multiple ? list : list.shift() || null);
},
};