Search code examples
phpapacheexif

exif_read_data() : working in terminal... not webserver - why?


I've build a small image gallery template for my personal needs and wanted to generate some of the content using the exif_read_data() function.

My PHP file works in the terminal... but accessing the website using a browser the output is cut whereever I call this function.

Is there any special configuration needed to get this to work in Apache HTTPD too?

Here is the PHP code used:

$dir = opendir("images");
while ($file = readdir($dir)) {
    if (substr($file, -4) == ".jpg") {
        $exif    = exif_read_data("images/$file", 0, true);
        $date    = str_replace(":", "-", $exif['EXIF']['DateTimeOriginal']);
        $comment = $exif['EXIF']['Comment'];
        echo("<li><a href=\"images/$file\" title=\"$comment\"><img src=\"thumbs/$file\" /></a><span>$date</span></li>\n");
    }
}
closedir($dir);

The output using php index.php is the following:

<li><a href="images/P1150624.jpg" title=""><img src="thumbs/P1150624.jpg" /></a><span>2012-01-15 18-16-54</span></li>
<li><a href="images/P1150639.jpg" title=""><img src="thumbs/P1150639.jpg" /></a><span>2012-01-15 19-09-25</span></li>
<li><a href="images/P1150588.jpg" title=""><img src="thumbs/P1150588.jpg" /></a><span>2012-01-15 15-38-53</span></li>
<li><a href="images/P1150601.jpg" title=""><img src="thumbs/P1150601.jpg" /></a><span>2012-01-15 16-31-41</span></li>
<li><a href="images/P1150635.jpg" title=""><img src="thumbs/P1150635.jpg" /></a><span>2012-01-15 19-08-28</span></li>

Using PHP v5.3.9 with --enable-exif and an older Apache v2.0.53...


Solution

  • Never mind... dumb as I am my httpd uses another installation of PHP... just found out using phpinfo() in the website.

    Terminal using PHP v5.3.9 - Webserver using PHP v5.2.11