Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

Laravel Storage not storing created PDF files

I am facing an issue where my created PDF's are not being stored in laravel.

I have the following set in my filesystems.php under the disks tag

'completedforms' => [
        'driver' => 'local',
        'root' => storage_path('app/storage/completedforms'),
    ],

In my controller I have the following:

$pdf = PDF::loadView('report.form19',  compact('generalreport','monthlyRoll', 'nightsInMonth', 'groupfee', 'subs', 'wing','weeksinmonth', 'meetingnights', 'lastRollMap', 'month_name', 'totalmember', 'totalcadets', 'totalnco', 'totalto', 'totalofficer'));
Storage::disk('completedforms')->put('Form 19 - '.$month_name . ' ' . $lastRollMap->roll_year.'.pdf', $pdf->output());
    
return $pdf->download ('Form 19 - '.$month_name . ' ' . $lastRollMap->roll_year.'.pdf');

I have added use IlluminateSupportFacadesStorage; to my Controller

The pdf is created and downloads no issues, however the file is not being saved in the located as difined for the disk in the filesystems.php.

I have created the folder manually to ensure it exists. I have even set the file name to test.php to remove any variables fromm the file name

question from:https://stackoverflow.com/questions/65838090/laravel-storage-not-storing-created-pdf-files

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

storage_path already starts at: /storage, so change it like so:

'root' => storage_path('/desired'),

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...