snippetjavascriptCritical
How can I convert an image into Base64 string using JavaScript?
Viewed 0 times
howimageusingbase64convertcanstringjavascriptinto
Problem
I need to convert my image to a Base64 string so that I can send my image to a server.
Is there any JavaScript file for this? Else, how can I convert it?
Is there any JavaScript file for this? Else, how can I convert it?
Solution
You can use the HTML5 `
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).Context
Stack Overflow Q#6150289, score: 233
Revisions (0)
No revisions yet.