-
Notifications
You must be signed in to change notification settings - Fork 663
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
Re-select the same file doesn't work #871
Comments
I am experiencing the same type of issue. Selecting a file uploaded during a single control initialization does not seem to work. One can select other files, but any file uploaded can't be added again until the component is reinitialized. |
This behavior can be reproduced on the test webpage for the library http://valor-software.com/ng2-file-upload/, just select the same file two times in a row during an upload operation. Even after removing the file from the queue the file does not get added and the "Upload All" button remains disabled. |
In my own experience, this is the typical behavior of an HTML input tag. I've seen this issue on other websites that don't make use of ng2-file-upload. The input tag holds the previous value, and only kicks off an upload when that value changes. Selecting the same value again doesn't upload the file a second time. Here's my workaround: @ViewChild('fileInput') fileInput: any;
...
uploadFile() {
this.uploader.uploadAll();
this.fileInput.nativeElement.value = '';
} <input #fileInput id="file" type="file" ng2FileSelect [uploader]="uploader" (change)="uploadFile()"/> |
@benjcallaghan It works for me! But I write it code in the upload success callback function, like this.
|
This is more related to the input tag, but if you want to add some functionality to ng2-file-upload to natively handle this, a pull request would be more than welcome 😉 |
I use this,
|
public onChange($event: any): void { WORK FOR ME |
you need to empty the input file value after upload component
this will definitely works |
if (this.selectedFiles.length === 0) { this.epubFileUploader.nativeElement.value = ''} worked for me.. |
|
I don't understand your work-a-round but it solves the problem. I know it is a while ago but I would greatly appreciate it if you could explain it or point me to a reference as to what is happening here. (Aside: What is the data type of 'fileInput'?) Thanks |
If you have
For the record, I have no idea if such a workaround is good practice anymore. I have long since moved away from the project that used it, and I've moved away from the company that owns it. |
@benjcallaghan Thanks for the explanation. I still have not caught on to the details of how to programmatically directly interoperate with the html - I am still at the level of the Angular directives for that purpose. That being said, your work-a-round still proved good in my use case which is using Angular 16! |
Hello,
I noticed that when selecting a file, then I remove it, then I try to select the same file, I am not able to do it.
In my case I am using the Single file select. My app is Angular 4.
Any idea how to change this behavior?
Thanks
The text was updated successfully, but these errors were encountered: