Coder_sLaY Coder_sLaY - 5 months ago 70
Javascript Question

How to convert image into base64 string using javascript

I need to convert my image to a base64 string so that i can send my image to a server.
Is there any js file for this... ? Else how to convert it

Answer

You can use the HTML5 <canvas> for it:

Create a canvas, load your image into it and then use toDataURL() to get the base64 representation (actually, it's a data: URL but it contains the base64-encoded image).

Comments