redarrow Posted March 12, 2013 Share Posted March 12, 2013 <?php $files = glob("kenai_river_fishing_images/*.*"); for ($i=1; $i<count($files); $i++) { $num = $files[$i]; print $num."<br />"; echo '<img src="'.$num.'" alt="kenai river fishing images" width="200px" height="200px" />'."<br /><br />"; } ?> hi there all my code is not working. the images dont show up. i am trying to show around 1500 images from a directory. directory corectly done , there no errors just print num works? any idea please. thank you. Quote Link to comment https://forums.phpfreaks.com/topic/275543-image-code-problam/ Share on other sites More sharing options...
AyKay47 Posted March 12, 2013 Share Posted March 12, 2013 What is returned from glob is an array of files that match the given pattern as I assume you already know. However if you are going to use that data directly in an <img> tags src attribute, you will need to specify a path to the directory where the images are stored. As of now the code above assumes that all of the images are in the same directory as the active file directory. Something like this: echo '<img src="/kenai_river_fishing_images/{$num}" alt="kenai river fishing images" width="200px" height="200px" />'."<br /><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/275543-image-code-problam/#findComment-1418158 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.