I have the following code:
JavaScript
x
2
1
<input type="file" #fileInput ng2FileSelect [uploader]="uploader" (onFileSelected)="onFileSelected($event)" />
2
And handler:
JavaScript
1
4
1
public onFileSelected(e: FileList): void {
2
this.form.patchValue({ filename: e[0].name });
3
}
4
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.
JavaScript
1
7
1
<input id="fileInput" onclick="fileClicked()" type="file">
2
<script>
3
function fileClicked(){
4
document.getElementById("#fileInput").value = "";
5
}
6
</script>
7