I have the following code:
<input type="file" #fileInput ng2FileSelect [uploader]="uploader" (onFileSelected)="onFileSelected($event)" />
And handler:
public onFileSelected(e: FileList): void {
this.form.patchValue({ filename: e[0].name });
}
Problem is when I try to select the same file, selected before, input does not chnaged and dont send event: e: FileList
Advertisement
Answer
You need to reset the input file value when pressing the input file button.
<input id="fileInput" onclick="fileClicked()" type="file">
<script>
function fileClicked(){
document.getElementById("#fileInput").value = "";
}
</script>