'FPDF return the files on PHP instead on PDF when I use a POST FORM
I am working on a generate PDF button that it's a POST method and this POST opens to you a new window opens a PDF. (Until here all nice). But when I try to download instead the name report.pdf appears report.php.
Do you know what can it happening?
Here I left to you the code what I output FPDF:
header("Content-type:application/pdf");
$filename = 'Report -'.date("d-m-Y").'.pdf';
$pdf->Output($filename,'I');
And this is what happens when I click to download on the PDF
Solution 1:[1]
It's not completely clear to me, what you mean by "when I click to download on the PDF". Maybe it works with a Content-Disposition-Header:
$filename = 'Report -'.date("d-m-Y").'.pdf';
header("Content-type:application/pdf");
header('Content-Disposition: attachment; filename="'.$filename.'"');
$pdf->Output($filename,'I');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Onki Hara |

