javascript - Load image from a url and convert it to a base64string -


this question has answer here:

i trying load image url , convert base64 string.

all string when use html source of image, images blank.

what doing wrong?

function getbase64image(imgurl) {             var image = new image();             var canvas = document.createelement("canvas");             var context = canvas.getcontext('2d');             image.src = imgurl;             context.drawimage(image,0,0);             return canvas.todataurl();         } 

the function returns string.

thank you.

simple way that:

$image = file_get_content($url); $result = "data:image/png;base64,". base64_encode($image); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -