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