Jump to content

Calling directory images to display


richard_PHP

Recommended Posts

Hello all,

 

Back again with yet another problem. I've got and upload to directory form and also an unlink form function all well and fine. However, on the viewing side I'm wanting the images uploaded using said forms to be displayed in their thumbnail form (eg- 1thumb.jpg) and then link to a larger version in their normal image size (eg- 1.jpg).

 

So far I have the following code mustered up which displays the thumbnail. However, my query is how to link to the actual image it is for (so 1thumb.jpg links to 1.jpg, 2thumb.jpg links to 2.jpg, 3thumb.png leads to 3.png etc etc).

 

Code:

$directory = "portimg/";
				$images = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE);
				$thumbs = glob("" . $directory . "{*thumb.jpg,*thumb.gif,*thumb.png}", GLOB_BRACE);
				//print each file name
				if (is_array($thumbs)) {
					foreach($thumbs as $thumb) { echo "<a href='" . $image . "'><img src='" . $thumb . "' /></a>"; }
					}
				else {
					echo "<p>No files present</p>";
					}
			?>

 

Many thanks!!

Link to comment
https://forums.phpfreaks.com/topic/264961-calling-directory-images-to-display/
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.