how to make a maximum 1MB upload image?

You can determine upload or not in before-upload. If image’s size less than 1MB, cancel the upload.

<el-upload>
  :before-upload="isImageValid"
</el-upload>

methods: {
  isImageValid(image) {
    const imageSize = image.size / Math.pow(1024, 2)
    if (imageSize < 1) return false
    return true
  }
}

Leave a Comment