如何将生成的二维码保存到laravel?

How to save generated qr Code in laravel?

我已经使用 "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

你可以试试 public

Storage::disk('public')->put($output_file, $image); //storage/app/public/img/qr-code/img-1557309130.png