fix: file upload limit

This commit is contained in:
louis 2024-04-11 09:04:56 +08:00
parent c3fe96eb86
commit 0383ec977e
2 changed files with 7 additions and 7 deletions

View File

@ -43,12 +43,12 @@
if (!isJpgOrPng) {
message.error('You can only upload JPG/PNG file!');
}
const isLt2M = file.size / 1024 / 1024 < 30;
if (!isLt2M) {
message.error('Image must smaller than 30MB!');
const isLt = file.size / 1024 / 1024 < 50;
if (!isLt) {
message.error('Image must smaller than 50MB!');
}
return isJpgOrPng && isLt2M;
return isJpgOrPng && isLt;
};
const uploadAvatar = async (file: FileType) => {

View File

@ -13,7 +13,7 @@
@cancel="onCancel"
>
<a-flex justify="space-between" align="center">
<a-alert message="单个文件不超过30MB最多只能上传10个文件" type="info" show-icon />
<a-alert message="单个文件不超过50MB最多只能上传10个文件" type="info" show-icon />
<a-upload :multiple="true" :before-upload="beforeUpload" :show-upload-list="false">
<a-button type="primary"> 选择文件 </a-button>
</a-upload>
@ -88,8 +88,8 @@
};
const beforeUpload: UploadProps['beforeUpload'] = async (file) => {
if (file.size / 1024 / 1024 > 30) {
message.error('单个文件不超过30MB');
if (file.size / 1024 / 1024 > 50) {
message.error('单个文件不超过50MB');
} else {
const item: FileItem = {
file,