Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileUpload: Custom upload bug on clear list #1723

Closed
vt167098 opened this issue Nov 3, 2021 · 5 comments
Closed

FileUpload: Custom upload bug on clear list #1723

vt167098 opened this issue Nov 3, 2021 · 5 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working vue2-portable
Milestone

Comments

@vt167098
Copy link

vt167098 commented Nov 3, 2021

How to clear the file list of fileupload(basic mode) after the upload is successful?

Now after the upload is complete, you cannot re-select other files to upload.

@vt167098 vt167098 changed the title FileUpload: How can do clear file lists at uploaded successful? FileUpload: How can do clear file lists at uploaded successful?(basic mode) Nov 4, 2021
@MattSala
Copy link

MattSala commented Dec 3, 2021

I'm having a similiar issue when using Custom Uploader with Vue 3. There should be a callback that clears the component. I have posted this issue in PrimeLand discord and was informed it's most likely a bug.

@plenexy
Copy link

plenexy commented Dec 16, 2021

Also faced this problem.
So far I have solved it in another way.

Specified at FileUpload key = "data.uploadKey"
default uploadKey = 0

After custom uploading the files, I increase the key value by 1. The component is cleared

@tugcekucukoglu tugcekucukoglu added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jan 27, 2022
@Davidpsj
Copy link

Davidpsj commented Mar 9, 2022

One way that I fix this issue is put a ref (fileUpload) on FileUpload component and inside the uploader handler the following implement:

this.$refs.fileUpload.clear();
this.$refs.fileUpload.uploadedFileCount = 0;

After upload successfully, the uploadedFileCount no make sense to another uploading flow in my case, so I reset the count.
Note: I'm using primevue 2.9.0. This issues is present yet.

@tugcekucukoglu tugcekucukoglu added this to the 3.13.0 milestone Mar 14, 2022
@tugcekucukoglu tugcekucukoglu self-assigned this Mar 14, 2022
tugcekucukoglu added a commit that referenced this issue Mar 14, 2022
Fixed #1723 - Clear file list after upload
@tugcekucukoglu tugcekucukoglu changed the title FileUpload: How can do clear file lists at uploaded successful?(basic mode) FileUpload: Custom upload bug on clear list Mar 14, 2022
@tmlmt
Copy link

tmlmt commented Feb 1, 2023

I'm using primevue 3.21.0 with Nuxt 3.0.0 and I still have this problem mentioned here with a custom uploader.
Had to use the fix proposed by @Davidpsj to be able to upload again after having uploaded once.
Am I doing anything wrong?

Here's my uploader:

const uploader = async (event: FileUploadUploaderEvent) => {
  const formData = new FormData();

  // MimeType Check on all files
  let filesToSend = 0;
  const filesToHandle = Array.isArray(event.files)
    ? event.files
    : [event.files];
  for (const f of filesToHandle) {
    const valid = await validateImageMimeType(f);
    if (valid) {
      formData.append("images", f);
      filesToSend += 1;
    } else {
      console.log("Unauthorised type")
    }
  }

  if (filesToSend > 0) {
    const { data, error } = await useFetch<string[]>(
      "/api/images",
      {
        method: "POST",
        body: formData,
      }
    );

    if (error.value) {
      console.log("Error")
    }

    if (data.value) {
      console.log("Hurray!")
      imageSrc.value = data.value;
    }
  }
  // If I don't add these two lines, I can't upload again after having uploaded once
  fileUpload.value.clear();
  fileUpload.value.uploadedFileCount = 0;
};

And my component :

<FileUpload
      name="image[]"
      :customUpload="true"
      accept="image/*"
      :maxFileSize="10000000"
      :multiple="true"
      :fileLimit="1"
      ref="fileUpload"
      @uploader="uploader"
    >
      <template #empty>
        <div class="flex align-items-center justify-content-center flex-column">
          <i class="pi pi-cloud-upload text-7xl text-500" />
          <p class="mt-4">Drag and drop images to upload</p>
        </div>
      </template>
    </FileUpload>

@Jeffrey-IKUU
Copy link

Bug is still here. I had to use the same solution to reset the limit. The removeUploadedFileCallback() was working just fine, the files[] and uploadedFiles[] are cleared but the uploadCount is not. @tugcekucukoglu "nuxt-primevue": "^0.2.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working vue2-portable
Projects
None yet
Development

No branches or pull requests

7 participants