Thanks for the reply Bogu
I'm trying to create a download of a pdf file. On my web site I am showing information and would like the visitor to be able to download the information as a pdf file.
So when they click "download this information" the fpdf creates a pdf file and forces a download. I can create the file but I'm stuck at the command "output".
It is made of 2 parts
string Output([string name [, string dest]])
Destination is
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.
S: return the document as a string. name is ignored.
When I do Output($filename,"F") it is saved on the server but when I do "D" nothing happens.
I've found this function for outputs with different browsers.
function output($filename)
{
if ($this->_state < 3) { // If document not yet closed
$this->close(); // close it now.
}
/* Make sure no content already sent. */
if (headers_sent()) {
die('Unable to send PDF file, some data has already been output to browser.');
}
/* Offer file for download and do some browser checks
* for correct download. */
$agent = trim($_SERVER['HTTP_USER_AGENT']);
if ((preg_match('|MSIE ([0-9.]+)|', $agent, $version)) ||
(preg_match('|Internet Explorer/([0-9.]+)|', $agent, $version))) {
header('Content-Type: application/x-msdownload');
Header('Content-Length: ' . strlen($this->_buffer));
if ($version == '5.5') {
header('Content-Disposition: filename="' . $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
} else {
Header('Content-Type: application/pdf');
Header('Content-Length: ' . strlen($this->_buffer));
Header('Content-disposition: attachment; filename=' . $filename);
}
echo $this->_buffer;
}
The manual explains about headers (and footers) for the page content not headers for the file types etc.
I need help with this please.