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

Ryan Carmelo Briones mexnix at craonline.org
Thu May 29 17:56:53 CDT 2003


i thought this was interesting, so i decided to check it out. after a couple
different tries, i looked at what the php docs on the PDFLib had to say. [
http://www.php.net/manual/en/ref.pdf.php ] interestingly enough, there's an
example ( search for "The script getpdf.php just returns the pdf
document." ) that doesn't work as well. at least, _I_ couldn't get it to
work. if this is for a company, you might think about buying the pdflib. if
anything, it should be fun to work with.

-------------------------------
ryan carmelo briones
e: mexnix at craonline.org
w: http://www.mexnix.org


----- Original Message ----- 
From: "Phillip Tyre" <phillip.tyre at fcul.com>
To: <tallahassee-pm at mail.pm.org>
Sent: Thursday, May 29, 2003 6:25 PM
Subject: [Tallahassee-pm] PDF's from a directory outside the server root


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();
?>




More information about the Tallahassee-pm mailing list