filereader is not working in angular 2 angular 4
filereader is not working in angular 2 angular 4. I found that
Filereader needs fileReader.readAsDataURL(event.target.files[0]) to start reading the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
onSelectFile(event) { // called each time file input changes // this.uploader.onSelectFile1(event); if (event.target.files && event.target.files[0]) { const fileReader: FileReader = new FileReader(); console.log(event); fileReader.onloadstart = (e:any)=>{console.log(e)}; fileReader.onload = (event: Event) => { console.log(fileReader.result); }; fileReader.onerror = (e:any)=>{console.log(e)}; fileReader.readAsDataURL(event.target.files[0]); //reading the file } } |