ElemeFE / ElemeFE/element

[Feature Request] el-upload - onBeforeUpload should use promise

Open
#20,234 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
Vue
Stars
54k
Forks
14.4k
PR merge metrics
No merged PRs in 30d

Description

### Existing Component
Yes

### Component Name
el-upload

### Description
I have my code :
```
async onThumbBeforeUpload(file) {
const { height, width } = await this.imageInfo(URL.createObjectURL(file))
const isImg = file.type === 'image/jpeg' || file.type === 'image/png'
const ishcn = width < height 200
const isLt2M = file.size / 1024 / 1024 < 2
if (!isImg) {
this.$message.error('Image must be JPG or PNG format!')
}
if (!isLt2M) {
this.$message.error('Image size can not exceed 2MB!')
}
if (!ishcn) {
this.$message.error('The photo must be a rectangle')
}
// if (isImg && isLt2M && ishcn) {
// this.thumb.status = 'uploading'
// }
return false
},
```

onBeforeUpload can't a promise when i check size image.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.