adam291086 Posted April 6, 2008 Share Posted April 6, 2008 I have a simple script to display all files within a folder. I want to remove the . and .. any clues? if ($handle = opendir('images')) { while (false !== ($file = readdir($handle))) { ?> <td> <img src= "images/<?php echo $file ?>" width="90" height="90" id="1" onclick="parent.replace_img('images/<?php echo $file ?>')"> </td> <td> <?php } closedir($handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/99825-solved-displaying-everything-in-a-folder/ Share on other sites More sharing options...
marcus Posted April 6, 2008 Share Posted April 6, 2008 let's use glob in this example. $folder = glob("images/*.png"); # png could be jpeg, jpg, bmp, gif... foreach($folder AS $file){ echo "<img src=\"".$file."\"><br>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/99825-solved-displaying-everything-in-a-folder/#findComment-510553 Share on other sites More sharing options...
adam291086 Posted April 6, 2008 Author Share Posted April 6, 2008 you say png can be jpeg, jpg, bmp, gif... well when i use it non of the images will load. Any other method? Quote Link to comment https://forums.phpfreaks.com/topic/99825-solved-displaying-everything-in-a-folder/#findComment-510565 Share on other sites More sharing options...
maexus Posted April 6, 2008 Share Posted April 6, 2008 The code he posted was specific to pngs. Do you have any png's in the folder? Are you sure you have the path right in glob for your image directory? http://us.php.net/glob For more info Quote Link to comment https://forums.phpfreaks.com/topic/99825-solved-displaying-everything-in-a-folder/#findComment-510567 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.