fix: file upload limit
This commit is contained in:
parent
c3fe96eb86
commit
0383ec977e
|
@ -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) => {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue