Hi all,
I'm using PHP 4.2.3 and Apache 1.3 on Linux. I'm trying to create a PHP program which will fetch a PDF file from outside the webserver's document root filesystem and display it to the user inline in the browser. My program so far looks like this:
<?php
$file = "/var/docs/test.pdf";
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: inline; filename=$file");
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, 4096);
}
fclose ($fd);
?>
It almost works, but not quite. When I load the page (pdftest.php), the browser pops up a window asking if I want to open the file or save it, which is not what I want. On the other hand, if I move the PDF file into the webserver document root directory and link to it directly, it opens with Acrobat in the browser immediately, which is the behavior I'm looking for, but I don't want to store my PDF files in the webserver filesystem, for various reasons.
Is there any combination of headers that will make this program do what I want?
Thanks,
Steve