Answers for "show pdf file in laravel"

PHP
1

display pdf file in laravel

Route::get('/pdf/{file}', function ($file) {
      // file path
     $path = public_path('storage/file' . '/' . $file);
      // header
     $header = [
       'Content-Type' => 'application/pdf',
       'Content-Disposition' => 'inline; filename="' . $file . '"'
     ];
    return response()->file($path, $header);
})->name('pdf');
Posted by: Guest on October-19-2021
1

how to save information on pdf file in laravel project

$pdf = PDF::loadView('pdf.invoice', $data);

Storage::put('public/pdf/invoice.pdf', $pdf->output());

return $pdf->download('invoice.pdf');
Posted by: Guest on October-02-2020
0

upload a pdf file laravel

class FileController extends Controller
{
    // ...

    public function upload(Request $request)
    {
        $uniqueFileName = uniqid() . $request->get('upload_file')->getClientOriginalName() . '.' . $request->get('upload_file')->getClientOriginalExtension());

        $request->get('upload_file')->move(public_path('files') . $uniqueFileName);

        return redirect()->back()->with('success', 'File uploaded successfully.');
    }

    // ...
}
Posted by: Guest on October-06-2021

Browse Popular Code Answers by Language