Realpath in pdflib & apache2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux