I havn't used the readfile function, the last passthru I done was this way:
Code: Select all
<?php
if(!($fp = fopen($filename, "rb"))) // rb for read/binary
die("Failed to open " . $filename);
else
{
header("Content-type: application/pdf"); // or whatever
fpassthru($fp);
fclose($fp);
}
?>
I think you need rb for windoze, but only r for linux...
Let me know how this goes.
Oh one more thing, I've noticed if u use cookies or sessions, applications like excel (dunno about application/pdf) won't actually send out cookies when they retrieve the file... (I would have thought the browser saves & excel opened, but not so it seemed in my case).
Does that make sense? If not, and you DO use some sort of login authority to view this pdf, then try NOT doing any security checks.
PS. I havn't tested it or anything so hopefully my memory serves me right and the syntax is ok