gpt4 book ai didi

php - 如何在 laravel 中保存生成的二维码?

转载 作者:行者123 更新时间:2023-12-05 08:31:43 26 4
gpt4 key购买 nike

我使用“simplesoftwareio/simple-qrcode”生成了二维码:https://github.com/SimpleSoftwareIO/simple-qrcode

现在我想将生成的图像保存在我的本地驱动器中。我该怎么做?

 public function qr($id)
{

$data = Ticket::get()->find($id);
$image = \QrCode::format('png')
->merge('img/t.jpg', 0.1, true)
->size(200)->errorCorrection('H')
->generate('A simple example of QR code!');
return response($image)->header('Content-type','image/png');

return view('qrCode', compact('qrData', $qrData));
}

最佳答案

你可以试试

$image = \QrCode::format('png')
->merge('img/t.jpg', 0.1, true)
->size(200)->errorCorrection('H')
->generate('A simple example of QR code!');
$output_file = '/img/qr-code/img-' . time() . '.png';
Storage::disk('local')->put($output_file, $image); //storage/app/public/img/qr-code/img-1557309130.png

关于php - 如何在 laravel 中保存生成的二维码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56037730/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com