$id = $this->request->request('id');
header('Content-Type: image/png');
vendor("phpqrcode.phpqrcode");//引入工具包
$qRcode = new \QRcode();
$data = SIMG_URL.'/webauth/index?store_id='.$id;//网址或者是文本内容
// 纠错级别:L、M、Q、H
$level = 'L';
// 点的大小:1到10,用于手机端4就可以了
$size = 10;
// 生成的文件名
$qRcode->png($data, false, $level, $size, 2);
Header('Pragma: public'); // required
Header('Expires: 0'); // no cache
Header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
Header('Cache-Control: private',false);
Header('Content-Type: application/force-download');
Header('Content-Disposition: attachment; filename="'.$id.'.png"');
Header('Content-Transfer-Encoding: binary');
Header('Connection: close');
做个记录,下次直接用。