I am generating dynamic PDF reports in PHP and having some issues with links to the web.
My links are to a PHP script that forces the download of a file attachment. This script works perfectly in all browser when accessed via the browser. It also works from the PDF in all browser except Internet Explorer.
Instead of IE seeing the file as a PDF, PNG, or whatever the file is, the download prompt says the document type is: "HTML Plugin Document"
If the user clicks "Open" or "Save" IE says it cannot download the file and gives the filename as "index2.php". That is the beginning of the URI of address.
The correct filesize is given so I know it is getting the file. Maybe it is a header issue?
Here is the header I'm creating on the download script:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT;"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT;"); header("Pragma: no-cache;"); // HTTP/1.0 header('Content-Type: '.$file->file_mime_type.';'); header("Content-Description: File Transfer"); header("Cache-Control: public"); header('Content-Disposition: attachment; filename="'.$file->file_name.'";'); header('Content-Length: '.$file->file_size.';'); header('Content-transfer-encoding: binary');
Any input would be greatly appreciated.
Here's what I use and that is proven to work: