I try to encode my image to base64 data string, but I have problem with output result. My base64 string is very short to has a valid data. If I print it in test div, I have normal and long string. Where the problem I don't know. I want to use my code for previewing logo.
function readURL(input, object) {
if (input.files && input.files[0])
{
var reader = new FileReader();
reader.onload = function (e)
{
$(object).attr('style', 'background-image :url("' + e.target.result + '")');
console.log(e.target.result);
}
reader.readAsDataURL(input.files[0]);
}};
This is my function...
$("#company_avatar").change(function(){
readURL(this, '#company_avatar_preview');});
And this function in use.