I am serving out files in PHP. In Windows, IE, Safari, and Firefox successfully downloads the file. On a Mac, Safari downloads fine. But Firefox on the Mac does not know what to do with the file and asks to either save the PHP file or try to open the PHP file. If I save the PHP file and rename it correctly to the actual file (PDF), then it opens fine. Why is the Mac Firefox version not able to properly rename the file and identify its content-type? My code below:
$content = file_get_contents('/tmp/file.pdf');
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//hack to allow PDF file downloads over HTTPS for Internet Explorer 8
if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("X-Download-Options: noopen ");
header("X-Content-Type-Options: nosniff");
}
header("Content-type:application/pdf");
echo $content;
I was able to solve it by adding: