fpdf Output('filename.pdf','F'); downloading file on browser instead of saving it on the server

user3766591 picture user3766591 · Mar 18, 2015 · Viewed 90.9k times · Source

When running code the file is the pdf file is getting saved in the browser instead of it getting saved on the server

fpdf Output('filename.pdf','F'); 

downloading file on browser instead of saving it on the server

Answer

Veve picture Veve · Mar 18, 2015

As explained in the FPDF documentation, you have to use the D as parameter to the output function to send the PDF to the browser and force a file download with the name given by name:

Output('D','filename.pdf');

For reference, here are the different values for the destination parameter:

I: send the file inline to the browser. The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name (may include a path).
S: return the document as a string. name is ignored.