-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
  }
4
  • Possible duplicate of How to upload a CSV file and read them using angular2? Commented Aug 2, 2017 at 7:08
  • Possible duplicate of Angular2 file input onchange Commented Aug 2, 2017 at 7: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 Commented Aug 2, 2017 at 7: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 Commented Aug 2, 2017 at 7:12

1 Answer 1

-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

Sign up to request clarification or add additional context in comments.

1 Comment

i am not getting the data present in the file, all i can get is the file name and the file type details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.