Sujeet Raman

Sujeet Raman

  • 864
  • 927
  • 352.9k

How to encode and decode image to base64 to save server

Jul 26 2017 10:20 AM
want to encode the uploaded files to base64 so that I can pass them to the request. The problem is that I'm using Angular 2 with Typescript and I couldn't find any info on how to do that. I found that in Javascript it can be done with canvas but I don't know how could I implement the code in Typescript. Even I need to know how to bind the coming base64 image in html please help me
 
What I have tried:
 
I am getting all other json data except base64.I need to bind it as an image.same way I need to post also
 
my html here, user can upload image here as jpeg
 
<input type="file" id="taxname" [(ngModel)]="spam.ImageData" class="form-control browse" value="Browse">
 
while binding am getting base64 only, how to convert this?. with in one API I need to get
 
<td> <span>{{ m.ImgeData }}</span> </td>
 
how can I achieve this?

Answers (1)