When using uploadHandler to implement custom upload, the selected file is not cleared. For example, I select the first file to upload, the file is succesfully added to my array. When I click the upload button again, I do not get the option to select a new file. Instead, the previous file I selected is added to the array again.
@brianjly Hello,
Why did you think that incorrect behavior? If you want upload new files - push "cancel" button to clear array of files after uploading.
Or, as an example, you can trigger that programmatically, like this
<p-fileUpload #form name="myfile[]" customUpload="true" (uploadHandler)="myUploader($event, form)"></p-fileUpload>
Where custom uploader looks like
myUploader(event, form){
for(let file of event.files) {
this.uploadedFiles.push(file);
}
form.clear();
}
@Sumragen thank you so much, just what I was looking for. closing the issue now
@Sumragen thank you :)
Hi,
When i wrote
myUploader(event, form){
console.log(form , "my file form")
for(let file of event.files) {
this.uploadedFiles.push(file);
}
form.clear();
}
then it is printing "undefined" at console
please suggest me i want to also clear selected file dynamically without clicking on cut button
when it has been uploaded
@himanshubudhlakoti
I think you just forgot to use #form
<p-fileUpload #form name="myfile[]" customUpload="true" (uploadHandler)="myUploader($event, form)"></p-fileUpload>
Hello there ...
Another thing I have noticed is that the "choose" button is disabled upon an error or wathever happens after trying to upload. How can I re-enable this button after trying/successfully uploading a file?
Most helpful comment
@brianjly Hello,
Why did you think that incorrect behavior? If you want upload new files - push "cancel" button to clear array of files after uploading.
Or, as an example, you can trigger that programmatically, like this
Where custom uploader looks like