element icon indicating copy to clipboard operation
element copied to clipboard

[Bug Report] The event "before-upload" in el-uploader is not really before upload, and we need a before-remove event.

Open niboac opened this issue 8 years ago • 6 comments

Element UI version

2.0.8

OS/Browsers version

all

Vue version

2.5.13

Reproduction Link

https://jsfiddle.net/niboac/x9xk4zws/1/

Steps to reproduce

upload a image bigger then 1Kb

What is Expected?

Do not call on-remove event

What is actually happening?

called on-remove event

niboac avatar Dec 21 '17 02:12 niboac

` upload(rawFile, file) {

  this.$refs.input.value = null;

  if (!this.beforeUpload) {
    return this.post(rawFile);
  }

  const before = this.beforeUpload(rawFile);
  if (before && before.then) {
    before.then(processedFile => {
      const fileType = Object.prototype.toString.call(processedFile);
      if (fileType === '[object File]' || fileType === '[object Blob]') {
        this.post(processedFile);
      } else {
        this.post(rawFile);
      }
    }, () => {
      this.onRemove(null, rawFile);
    });
  } else if (before !== false) {
    this.post(rawFile);
  } else {
    this.onRemove(null, rawFile);
  }
}`

其实上传时的那个on-remove什么也没做,只是简单的回调函数吧~

littlePig-zzf avatar Feb 06 '18 09:02 littlePig-zzf

很奇怪

Frank-Dell avatar Oct 29 '18 06:10 Frank-Dell

为什么要调那个onRemove?没理由。

gooqiao avatar Dec 04 '18 09:12 gooqiao

It tries to remove the file even before-upload comes with false.

This is an issue.

kikoseijo avatar Jun 05 '19 09:06 kikoseijo

TO give a better feedback, because I think this is a mayor issue.

I upload an image with not a valid extension, thus this, beforeUpload should not be called. But it does get called, I must do:

beforeRemove(file, fileList) {
      if (false === this.beforeAvatarUpload(file)) {
        return;
      }
     ...

and also

handleRemove(file, fileList) {
      if (false === this.beforeAvatarUpload(file)) {
        return;
      }
     .....

-So, seems before upload only works partial.

kikoseijo avatar Jun 05 '19 09:06 kikoseijo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 04 '20 11:06 stale[bot]