Script 11.6 View Uploads Plus
Read all image files from the uploads directory and create an image gallery with thumbnails and image meta data.
Adding the file size and date image was uploaded. When you click on a gallery preview, a new window will open with the full sized image.
Output
Click on a preview to view it fullsize in a separate window.
127A-620.jpg
Size 28kb
March 22, 2023 17:25:46
2wnbc6u.jpg
Size 64kb
October 29, 2013 12:10:12
587px-Ouroboros_2.jpg
Size 46kb
October 27, 2013 17:58:43
IMG_10012014_205921.png
Size 26kb
December 28, 2017 04:39:34
IW6200050011001.jpg
Size 135kb
December 20, 2020 03:35:50
IW6200050011001.jpg.php
Size 135kb
December 20, 2020 03:36:38
Purple-Butterfly.png
Size 144kb
April 25, 2014 16:47:36
WheelofLifeThangka.jpg
Size 218kb
October 29, 2013 12:22:55
chaos.jpg
Size 11kb
October 27, 2013 09:47:53
chief.jpg
Size 71kb
November 02, 2013 12:19:52
computer.jpg
Size 3kb
July 02, 2016 00:01:50
final.jpg
Size 34kb
October 27, 2013 11:05:15
final2.jpg
Size 59kb
October 27, 2013 09:47:01
head crusher.jpg
Size 8kb
October 29, 2013 13:42:02
josey.jpg
Size 101kb
April 26, 2014 15:37:36
kecil.png
Size 35kb
December 23, 2019 12:04:53
logo.thumbnail.png
Size 31kb
March 28, 2016 12:48:03
rexm.jpg.php
Size 1kb
December 20, 2020 03:37:38
som-bicycle-club-1888.jpg
Size 352kb
October 28, 2013 20:33:17
Source<p>Click on a preview to view it fullsize in a separate window.</p>
<div class="thumb-gallery">
<?php # Script 11.6 - images.php
// This script lists the images in the uploads directory.
// This version now shows each image's file size and uploaded date and time.
// Set the default timezone:
date_default_timezone_set ('America/New_York');
$dir = UPLOAD_DIR; // Define the directory to view.
$files = scandir($dir); // Read all the images into an array.
// Display each image caption as a link to the JavaScript function:
foreach ($files as $image) {
// Ignore system files starting with a period and any image with _th suffix
if(substr($image, 0, 1) != '.' && substr(substr($image, 0,strrpos($image,'.')),-3) != THUMB_SUFFIX) {
// Get the image's size in pixels:
$image_size = getimagesize("$dir/$image");
// Calculate the image's size in kilobytes:
$file_size = round ( (filesize ("$dir/$image")) / 1024) . "kb";
// Determine the image's upload date and time:
$image_date = date("F d, Y H:i:s", filemtime("$dir/$image"));
// Make the image's name URL-safe:
$image_name = urlencode($image);
// Print the information:
echo "<a class='gallery-item' href=\"javascript:create_window('$image_name',$image_size[0],$image_size[1])\">".getThumbnail($image)."<p class='image-meta'>$image<br /><span class='image-size'>Size $file_size</span><br /><span class='image-date'>$image_date</span></p></a>\n";
}
} // End of the foreach loop.
?>
</div>