I need to Encode an image to Base64 format and then I have to Decode the Base64 value to an image and display the image in a HTML Page. Now I encoded an Image to base64 with the below code,
getFiles(event) {
this.files = event.target.files;
//alert(this.files);
var reader = new FileReader();
reader.onload = this._handleReaderLoaded.bind(this);
reader.readAsBinaryString(this.files[0]);
//alert(this.files[0]);
}
_handleReaderLoaded(readerEvt) {
var binaryString = readerEvt.target.result;
this.filestring = btoa(binaryString); // Converting binary string data.
//alert(this.filestring);
//console.log(this.filestring);
}
Im getting the base64 value now t couldn't able to convert the base64 value to an image.