-1

i am using angular2 and am trying to get the data of the uploaded file .CSV file but i am not able to get the data of the file. The below is my code

html

<input type="file" name="File Upload" id="txtFileUpload" 
        (change)="changeListener($event)" 
        accept=".csv"/>

component

 changeListener(fileInput: any): void {
    debugger;
   //want to get the data of the uploaded file
  }
Lijin Durairaj
  • 3,341
  • 11
  • 31
  • 50
  • Possible duplicate of [How to upload a CSV file and read them using angular2?](https://stackoverflow.com/questions/45441962/how-to-upload-a-csv-file-and-read-them-using-angular2) – Matthias F. Aug 02 '17 at 07:08
  • Possible duplicate of [Angular2 file input onchange](https://stackoverflow.com/questions/38476315/angular2-file-input-onchange) – Rax Weber Aug 02 '17 at 07:09
  • that blog has not provided me the answer and i am trying to change the question and ask, the answer which someone has given is not to read the file nut to upload it in a particular location. i dont want to upload the CSV file, i want to read the uploaded .CSV file and get the data – Lijin Durairaj Aug 02 '17 at 07:11
  • i dont mind if someone down rate my question for possible duplicate for which i have not received any answer but before down rating please provide me with the answer... thank you – Lijin Durairaj Aug 02 '17 at 07:12

1 Answers1

-1

You can get it with this:

changeListener(fileInput: any): void {
    var file = event.srcElement.files[0];
}

this gives only this details enter image description here

Lijin Durairaj
  • 3,341
  • 11
  • 31
  • 50
thardes2
  • 1,162
  • 12
  • 28