-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Comments
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. |
Also faced this problem. Specified at FileUpload key = "data.uploadKey" After custom uploading the files, I increase the key value by 1. The component is cleared |
One way that I fix this issue is put a ref (fileUpload) on FileUpload component and inside the uploader handler the following implement:
After upload successfully, the uploadedFileCount no make sense to another uploading flow in my case, so I reset the count. |
Fixed #1723 - Clear file list after upload
I'm using primevue 3.21.0 with Nuxt 3.0.0 and I still have this problem mentioned here with a custom uploader. 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> |
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", |
It seems issue still there. The following solution worked for me:
|
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.
The text was updated successfully, but these errors were encountered: