Search code examples
laraveldompdf

file_put_contents(xxx.pdf): failed to open stream: No such file or directory"


I am using barryvdh/laravel-dompdf to create my pdf documents. I've created a function in the controller to create the pfd. But now I want to save the pdf.

 $myData = array('data' => $data);

 if (!empty($data)){

   // Send data to the view using loadView function of PDF facade
   $pdf = PDF::loadView('pdf.invoice', $myData);

   // If you want to store the generated pdf to the server then you can use the 
   store function

   // Finally, you can download the file using download functio
   $pdf->save(storage_path('invoices\INV'.$year.Auth::user()->lab_id.'.pdf'));

   return $pdf->download('invoice.pdf');
 }

However now I get the error message

file_put_contents(C:\laragon\www\WebPTS\storage\invoices\INV201846.pdf): failed to open stream: No such file or directory

Please assist.


Solution

  • I m,anaged to get a document to load these files on Dropbox. https://itsolutionstuff.com/post/laravel-5-dropbox-api-file-upload-example-using-league-flysystem-dropbox-packageexample.html