arthur arthur - 3 months ago 25
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?

require_once(APPLICATION_PATH.'/library/phpqrcode-master/qrlib.php');
ob_start();
\QRcode::png($id, null, 'M', 8, 2);
$endingOutput = ob_get_contents();
ob_end_clean();

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

Answer

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.

Comments