Jump to content

image code problam


redarrow

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.