this is based on the first tutorial file from the FPDF package (www.fpdf.org).
It's working, but the filename in the saveas dialog is always the name of the php file which creates the pdf... in this case, tuto1.pdf. (tuto1.php was the executed script)
What could the problem be? Oh, and it DOES WORK under Firefox! The problem shows up with IE6.
thanks
function CleanFiles($dir)
{
//Delete temporary files
$t=time();
$h=opendir($dir);
while($file=readdir($h))
{
if(substr($file,0,3)=='tmp' and substr($file,-4)=='.pdf')
{
$path=$dir.'/'.$file;
//if($t-filemtime($path)>3600)
@unlink($path);
}
}
closedir($h);
}
require('../fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
CleanFiles(getcwd());
$pdf->Cell(40,10,"text");
// make tempfile
$file=basename(tempnam(getcwd(),'tmp'));
rename($file,$file.'.pdf');
$file.='.pdf';
$pdf->Output($file);
header('Content-type: application/pdf');
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header("Content-Length:". filesize($file));
header("Content-Disposition: attachment; filename=\"whatever.pdf\"");
set_time_limit(0);
readfile($file);