You can try a link with the "download" attribute: http://www.w3schools.com/tags/att_a_download.asp
Although this only works in html5
PS. I wouldn't recommend storing PDFs in the database, since it could cause some performance issues.
Hello everybody, i'm triyng to force download a pdf file that is stored in a base64 string in my database.
I'm using a link and it doesn't download the file, it opens a page with the pdf.
First of all what should i use in your opinion? A button, a link.. something else? Here is the method i use to output my file
public function getPdf(Request $request)
{
$pdf_id = Input::get('pdf_id');
$result = DB::table('pdf_contents')
->select('pdf')
->where('id',(int)$pdf_id)->first();
$base_64_pdf = $result->pdf;
$pdf = base64_decode($base_64_pdf);
return (new Response($pdf,200))->header('ContentType','application/pdf');
}
Thanks in advance
Please or to participate in this conversation.