OutForCode
OutForCode

Reputation: 461

QRcode generated not storing in the path given

Using SimpleSoftwareIO/simple-qrcode, I am trying to generate QRCode and store it.

\QrCode::generate($reservation_id, '/assets/uploads/'.$reservation_id.'.svg');

Which returns following error,

"file_put_contents(/assets/uploads/15525609678807.svg): failed to open stream: No such file or directory",
"exception": "ErrorException",
"file": "/..../vendor/simplesoftwareio/simple-qrcode/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php",
"line": 85, 

Upvotes: 0

Views: 2192

Answers (2)

kaamrul
kaamrul

Reputation: 53

$path = '/assets/uploads/';
if(!\File::exists(public_path($path))) {
    \File::makeDirectory(public_path($path));
}
$file_path = $path . $reservation_id . '.svg';

\QrCode::generate($reservation_id, $file_path);

I hope it will help you, this is work fine for me.

Upvotes: 0

OutForCode
OutForCode

Reputation: 461

It works,

\QrCode::generate($reservation_id, base_path().$reservation_id.'.svg');

Upvotes: 2

Related Questions