How can I download a PDF file and Redirect the another Route in Laravel 5.1.
For Download a File
return response()->download($pathToFile);
How can I download a PDF file and Redirect the another Route in Laravel 5.1.
For Download a File
return response()->download($pathToFile);
That's how I have downloading a file in browser and it gets downloaded.
$fileName = "file.pdf";
if (file_exists($fileName)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($fileName).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileName));
readfile($fileName);
//You can redirect to any route from here.
exit;
}