Jump to content

Recommended Posts

<?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.

Link to comment
https://forums.phpfreaks.com/topic/275543-image-code-problam/
Share on other sites

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 />";
Link to comment
https://forums.phpfreaks.com/topic/275543-image-code-problam/#findComment-1418158
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.