It is very easy to convert image to Base64 String in JavaScript.
To convert you need jQuery library to your html.
Just pass the image to this below imageFileAsBase64(). Get the Base64 value for the image in imagebase64 variable.
- var imagebase64 = "";
- function imageFileAsBase64(element) {
- var file = element.files[0];
- var reader = new FileReader();
- reader.onloadend = function() {
- imagebase64 = reader.result;
- }
- reader.readAsDataURL(file);
- }
No comments:
Post a Comment