I have a situation where I need to upload an image in section X and pass the base 64 data of the uploaded image to section Y. But I am encountering some difficulties in section X
HTML:
<input type="file" id="hotspot" (change)="uploadHotSpot($event)">
TS File:
uploadHotSpot($event){
var file:File = $event.target.files[0];
var reader:FileReader = new FileReader();
if (file) {
reader.readAsDataURL(file); //reads the data as a URL
this.pin = reader.result;
console.log(this.pin);
}
}
Issue: I am able to successfully see the base 64 data in the console log when uploading the image with the developer tools open. However, when I close the debugger tool and try to upload the image again, the console.log is coming out blank... Any thoughts on this?