I have stored my pdf file in files folder inside public folder. Now, i have a "Download" button inside resources/views/admin/view_data.blade.php
How to download the pdf file when i click the download button??
I have stored my pdf file in files folder inside public folder. Now, i have a "Download" button inside resources/views/admin/view_data.blade.php
How to download the pdf file when i click the download button??
Try this. When you click on the button call a route and a method then use this code. You can change directory path.
public function getDownload()
{
//PDF file is stored under project/public/download/info.pdf
$file= public_path(). "/download/info.pdf";
$headers = array(
'Content-Type: application/pdf',
);
return Response::download($file, 'filename.pdf', $headers);
}
Just a small addition, if you are using an IDE the following will prevent any squarks
return response()->download($file, 'filename.pdf' ,$headers);