arthur arthur - 1 year ago 86
HTML Question

Generated QR code not displaying on mobile

I am using php qr code to generate a QR code. The code displays in browser, and stays when I shrink down the width to mobile, but it does not display at all on my mobile browser, both Chrome and and Firefox. Any ideas?

\QRcode::png($id, null, 'M', 8, 2);
$endingOutput = ob_get_contents();

return '<img src="data:image/png;base64,'.base64_encode($endingOutput).'" /><br/>' . $bitcoinID;

Answer Source

I am not sure of what was causing the issue exactly, but a workaround that fixed my problem was creating a div and creating the div's background url to be the base64 code. I was loading it in with ajax

var url = 'url(data:image/png;base64,' + data.base64 + ') no-repeat';
$("#somediv").css("background", url);

I also had to set the divs width and height for it to display.