Unable to select the file again , after remove #906

Open
opened 2017-10-10 05:28:47 +00:00 by NomiJ · 4 comments
NomiJ commented 2017-10-10 05:28:47 +00:00 (Migrated from github.com)

Hi,
In your demo, if I select a single file, add it and then remove it, I cannot select it again.
In demo code, you use item.remove() but does it remove from the queue as well?

Thanks

Hi, In your [demo](http://valor-software.github.io/ng2-file-upload/), if I select a single file, add it and then remove it, I cannot select it again. In demo code, you use `item.remove()` but does it remove from the queue as well? Thanks
rem99 commented 2017-10-11 11:13:00 +00:00 (Migrated from github.com)

Same problem. Seems it happens because old file still selected in input[type=file] element, and when you select same file, the onchange event doesn't fire.

Same problem. Seems it happens because old file still selected in input[type=file] element, and when you select same file, the onchange event doesn't fire.
souflam commented 2017-11-01 10:48:43 +00:00 (Migrated from github.com)

@NomiJ you cant try this :
add change event in your html
<input type="file" ng2FileSelect [uploader]="uploader" (change)="onChange($event);"/>
and in your component add this:
onChange(event:any):void{ event.srcElement.value = ''; }

@NomiJ you cant try this : add change event in your html ` <input type="file" ng2FileSelect [uploader]="uploader" (change)="onChange($event);"/> ` and in your component add this: `onChange(event:any):void{ event.srcElement.value = ''; }`
thorsten commented 2018-02-08 14:33:17 +00:00 (Migrated from github.com)

To avoid errors in Firefox, you should use this method:

public onChange(event: any): void { event.target.value = ''; }

To avoid errors in Firefox, you should use this method: ` public onChange(event: any): void { event.target.value = ''; }`
cedricseyve commented 2019-02-26 16:22:51 +00:00 (Migrated from github.com)

I linked my HTML input to my TS by using a ViewChild.

@ViewChild('selectFileField') private selectFileField: ElementRef;

I then did as told above but on "remove" event instead (on any item).

onRemoveItem(): void { this.selectFileField.nativeElement.value = ''; }

So I can still have the input field showing the file name instead of 'No file selected' or so.

I linked my HTML input to my TS by using a ViewChild. `@ViewChild('selectFileField') private selectFileField: ElementRef;` I then did as told above but on "remove" event instead (on any item). `onRemoveItem(): void { this.selectFileField.nativeElement.value = ''; }` So I can still have the input field showing the file name instead of 'No file selected' or so.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#906