![[衰]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_34.cf5b4d5.png)
antdesign upload上传文件默认的过滤可以通过选择所有文件绕过去、这个时候可以用beforeUpload做一次二次校验 beforeUpload(file: any) {
if (type) {
const isPass = checkFileMineType(file, type)
if (messageTip && !isPass) {
message.error('文件格式错误,请添加正确格式的文件(.xlsx或.xls的文件)')
return LIST_IGNORE
}
if (!isPass) {
message.error('文件类型不符合要求')
return LIST_IGNORE
}
}
if (file.size > maxSize.size) {
message.error(maxSize.message || '超出文件大小限制')
return LIST_IGNORE
}
if (maxSizeWH) {
return getFileWidthAndHeight(file, maxSizeWH?.[0], maxSizeWH?.[1])
}
return file
},
if (type) {
const isPass = checkFileMineType(file, type)
if (messageTip && !isPass) {
message.error('文件格式错误,请添加正确格式的文件(.xlsx或.xls的文件)')
return LIST_IGNORE
}
if (!isPass) {
message.error('文件类型不符合要求')
return LIST_IGNORE
}
}
if (file.size > maxSize.size) {
message.error(maxSize.message || '超出文件大小限制')
return LIST_IGNORE
}
if (maxSizeWH) {
return getFileWidthAndHeight(file, maxSizeWH?.[0], maxSizeWH?.[1])
}
return file
},
展开
评论
1