0
    $data = 'www.baidu.com'; 
    include 'phpqrcode.php';
    $QRcode = new \QRcode();
    ob_start();
    $QRcode->png($data);
    $imageString = base64_encode(ob_get_contents());
    ob_end_clean();

    echo $imageString;
    
    为什么上面的代码没有输出,要在php里直接生成二维码转base给前端?

2个回答

2

首先你要知道,输出二维码是个图片,你要设置下header吧

0
header('Content-type: image/jpeg');
header('Content-Disposition: attachment; filename=download_name.jpg');
readfile($yourFilePath);

撰写答案