richard_PHP Posted June 28, 2012 Share Posted June 28, 2012 Hello all, Back again with yet another problem. I've got and upload to directory form and also an unlink form function all well and fine. However, on the viewing side I'm wanting the images uploaded using said forms to be displayed in their thumbnail form (eg- 1thumb.jpg) and then link to a larger version in their normal image size (eg- 1.jpg). So far I have the following code mustered up which displays the thumbnail. However, my query is how to link to the actual image it is for (so 1thumb.jpg links to 1.jpg, 2thumb.jpg links to 2.jpg, 3thumb.png leads to 3.png etc etc). Code: $directory = "portimg/"; $images = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE); $thumbs = glob("" . $directory . "{*thumb.jpg,*thumb.gif,*thumb.png}", GLOB_BRACE); //print each file name if (is_array($thumbs)) { foreach($thumbs as $thumb) { echo "<a href='" . $image . "'><img src='" . $thumb . "' /></a>"; } } else { echo "<p>No files present</p>"; } ?> Many thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/264961-calling-directory-images-to-display/ Share on other sites More sharing options...
jcanker Posted June 29, 2012 Share Posted June 29, 2012 here you make var $images but reference $image (no trailing s). Quote Link to comment https://forums.phpfreaks.com/topic/264961-calling-directory-images-to-display/#findComment-1357857 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.