I have generated pdf file using fpdf but i'm getting the error. Adobe reader could not open the 'invoice.pdf' because it is either not a supported file type or because the file has been damaged. Any help would be greatly appreciated!
<?php
$f_name=$_POST['first-name'];
if(isset($_POST['submit']))
{
$f_name=$_POST['name'];
$l_name=$_POST['last-name'];
$email=$_POST['email'];
require("fpdf/fpdf.php");
$fpdf=new FPDF();
$fpdf->AddPage();
$fpdf->setFont("Arial","B",16);
$fpdf->Cell(0,10,"Invoice",1,1,"C");
$fpdf->Cell(95,10,"Name:",1,0,"C");
$fpdf->Cell(95,10,$f_name,1,1,"C");
$fpdf->Cell(95,10,"Last Name:",1,0,"C");
$fpdf->Cell(95,10,$l_name,1,1,"C");
$fpdf->Cell(95,10,"Email:",1,0,"C");
$fpdf->Cell(95,10,$email,1,1,"C");
$file_location = $_SERVER['DOCUMENT_ROOT']."/invoice/up_pdfs/".$f_name.".pdf";
file_put_contents($file_location,$fpdf);
ob_clean();
$fpdf->output();
header("Location: index.php");
}
?>