note 44572 deleted from function.pdf-open-image by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 10 Aug 2004 03:24:13 +0000 |
| Subject: | note 44572 deleted from function.pdf-open-image by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74373@lists.php.net to get a copy of this message | ||
Note Submitter: kermodebear -at- kermodebear -dawt- org
----
Unlike fopen(), the PDF library does NOT allow one to search for a file along the include path.
Where I work, the images used for document generation are kept in an include path, which is fine for
some applications, but PDFLib requires an absolute path.
This small function will take a relative path to a file and search the include structure, eventually
returning either the absolute path or false.
<?php
function get_absolute( $file ) {
$include_path = ini_get( 'include_path' );
$a_paths = split( ':', $include_path );
foreach( $a_paths as $path ) {
if ( is_file( $path . '/' . $file ) ) {
return $path . '/' . $file;
}
}
return false;
}
?>