[Tallahassee-pm] PDF's from a directory outside the server root

Phillip Tyre phillip.tyre at fcul.com
Thu May 29 17:25:01 CDT 2003


An interesting problem I'm facing is trying to use a PHP page to serve a
PDF file from a directory PHP has access to, but that APACHE does not.
 
Take for example an expenses.pdf file that might be updated every month
in the /home/accounting/ directory. I give PHP access to this directory,
and want to serve the PDF via a PHP page. I've found examples of how to
do this, and the following is the example of how I'm doing it. However,
it doesn't work consistently well across different versions/ clients of
IE.
 
Ideally I'd like the PDF to just open in the browser when the PHP page
is requested, hence my commenting of the attachment header. But on one
client (XP with IE 6.2800), this actually produced a text view of the
PDF file (all of the headers, all of the tags, escaped characters etc).
And yes the client had a PDF viewer.
 
Has anyone had any experience with this problem, or know of a good work
around?
 
Example PHP Script
<?php
$filesource="/home/accounting/expenses.pdf";
header("Content-type: application/pdf");
// header("Content-Disposition:attachment;filename=expenses.pdf");
readfile("$filesource");
page_close();
?>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/tallahassee-pm/attachments/20030529/7c52f61d/attachment.htm


More information about the Tallahassee-pm mailing list