Realpath in pdflib & apache2

From: Date: Mon, 14 Jun 2004 11:26:29 +0000
Subject: Realpath in pdflib & apache2
Groups: php.windows 
Request: Send a blank email to php-windows+get-23977@lists.php.net to get a copy of this message
When creating a pdf file using pdflib through php on Apache2, I have noticed that the default path for the filenames are different depending on where the filename is used. I wanted to open a template pdf file to save time by having all constant texts generated only once and reuse the template later. I am using something like this: $filename= "template.pdf"; if (file_exists($filename)) { // Use template file $form = pdf_open_pdi($pdf, $filename, "", 0); if ($form == 0){ die("Error: " . PDF_get_errmsg($pdf)); } ... ... } else { // No template, generate it ... ... } My problem is that I get an error message when pdflib tries to open the file. A template.pdf is located at c:/web/htdocs, which is the apache configuration for DocumentRoot. The problem is that pdflib looks for the template.pdf where the apache setting for ServerRoot is pointing, which is somewhere different. Obviously I can change DocumentRoot and the ServerRoot to resolve this, but I find that the location of apache binaries, logs, etc. and my web- site are two different issues and should not be mixed. The solution I have found is the use realpath() to resolve filenames to fully qualified names, e.g. $filename= realpath("template.pdf"). Is this the best way of doing this?

« previous php.windows (#23977) next »