I have a a pdf in public/downloads. I want to just link to it and have it download or open in browser. I tried hitting http://localhost:8000/downloads/brochure.pdf
in the browser but I just get a white screen with no errors. In Chrome DevTools > Network, it says the request was canceled. I'm inserting the URL via javascript so I can't use URL::to or link_to() like other answers on here have suggested.
Note: When I link to a css file in the same fashion as the brochure.pdf, the css appears in the browser.
Path to file can be achieved like:
public function getDownload(){
$file = public_path()."/downloads/info.pdf";
$headers = array('Content-Type: application/pdf',);
return Response::download($file, 'info.pdf',$headers);
}
function will download file from : 'project/public/downloads' folder.
(don't forget to set-up routes and controller by yourself)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With