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

View File

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