0

I have a PHP based image gallery using the Lightbox plug-in. When I run on MAMP, it works fine on a local server. However, it fails when I upload the files to an SFTP client for my website.

I have the following code:

<?php

$directory = 'SpringPhotos17';
$thumbsdirectory = 'SpringPhotos17/_thumb';

$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;

$dir_handle = @opendir($directory) or die("There is an error with your image directory!");

while ($file = readdir($dir_handle))
{
    if($file=='.' || $file == '..') continue;

    $file_parts = explode('.',$file);
    $ext = strtolower(array_pop($file_parts));

    $title = implode('.',$file_parts);
    $title = htmlspecialchars($title);

    $nomargin='';

    if(in_array($ext,$allowed_types))
    {
        if(($i+1)%4==0) $nomargin='nomargin';

        echo '
        <div class="pic '.$nomargin.'" style="background:url('.$thumbsdirectory.'/'.$file.') no-repeat 50% 50%;">
        <a href="'.$directory.'/'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a>
        </div>';

        $i++;
    }
}

closedir($dir_handle);

?>

I inserted this PHP code within the HTML code for an image gallery. On the website, it comes up as:

'.$title.'

How can I resolve this issue? Thank you for your time and help in advance!

  • It can be issue of server settings or document BOM and version of PHP. – daremachine May 14 '17 at 00:12
  • You may probably need to account for the absolute path of the directory on the server. See this [post](http://stackoverflow.com/q/6079479/2298301). – Dhruv Saxena May 14 '17 at 00:14
  • I'm not sure how to do this. The php code I included is embedded in HTML code I called "slideshow.html" I then tried to insert this into a tab on my website using: Do you think there is another issue at play? Thank you for your time – Naureen Ghani May 15 '17 at 17:25

0 Answers0