PHP image gallery help (echo (sub)folder)

I have made a simple PHP image gallery where I save each users pictures in a folder with their usernames.
Like this for example:
images\USERNAME\originalpicture.jpg
images\USERNAME\thumbs\thumb_originalpicture.jpg

To show the users pictures I use a code that shows all files in the folder images\USERNAME\thumbs\

But I have been trying to figure out how to make a link on each thumbnail so they can click on it to see the original picture.

I NEED HELP, can’t figure it out!

 
 <table border="0" width="600">
  <tr>
    <td>
<? $sessionnavn = $_SESSION['SESS_FIRST_NAME'];
echo '<h1>'.$sessionnavn.'`s album</h1>'; 
?>
<br>
<?php 

$files = glob("images/".$sessionnavn."/thumbs/*.*"); for ($i=0; $i<count($files); $i++) { $num = $files[$i];

echo '<img src="'.$num.'" alt="Opplastet bilde"></a>'."&nbsp;&nbsp;"; } ?>

</td></th>
</table>

You can use str_replace() function and apply it to thumbnail image path:

[php]$orig=str_replace(’/thumbs/thumb_’,’/’,$num);
echo ‘Opplastet bilde’."  ";[/php]

p.s. noticed small bug in your html code: you have opening

but closing is

[php]

<? $sessionnavn = 'My'; echo '

'.$sessionnavn.' album

'; ?>
<?php
        $files = glob("images/".$sessionnavn."/thumbs/*.*");
        for ($i=0; $i<count($files); $i++) {
            $num = $files[$i];
            echo '<a href="#"';
            echo ' onClick=window.open("'.$num.'","myimage","width=600,height=600")';
            echo '><img src="'.$num.'" alt="Opplastet bilde" width="100" height="100"></a>'."&nbsp;&nbsp;";
        } ?>

    </td></tr>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service