I am trying to convert any image to a Base64 String but not getting the output
See the screenshot what I am getting
Javascript code
function encodeImageFileAsURL(cb)
{
return function()
{
var file = this.files[0];
var reader = new FileReader();
reader.onloadend = function ()
{
cb(reader.result);
}
reader.readAsDataURL(file);
}
}
$('#inputFileToLoad').change(encodeImageFileAsURL(function(base64Img)
{
$('.output')
.find('textarea')
.val(base64Img)
.end()
.find('a')
.attr('href', base64Img)
.text(base64Img)
.end()
.find('img')
.attr('src', base64Img);
}));