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); } ?> 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"; } 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? 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 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
Archived
This topic is now archived and is closed to further replies.