In Angular 4,
HTML:
Typescript:
importFile(event) {
if (event.target.files.length == 0) {
console.log("No file selected!");
return
}
let file: File = event.target.files[0];
// after here 'file' can be accessed and used for further process
}
On considering the future issue of selecting same file not working, In input tag click event we are setting to null, which allows same file to select second time.