Good day to you all,
I'm building a little image directory viewer and I want it to list the images by date they were uploaded and within that by landscape or portrait.
I would need newest on top.
Here is the code I have so far :
PHP Code:
<?php
$val= $_GET['folder'];
$val.="/";
$imgdir = $val; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}
$totimg = count($a_img); // total image number
for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);
echo "<tr><td>";
if ($size[0] > "199"){
echo '<img src="'.$imgdir.'/'.$a_img[$x].'" width="50" border="0">';
}
echo "</td</tr>";
echo "<tr><td>";
if ($size[1] > "199"){
echo '<img src="'.$imgdir.'/'.$a_img[$x].'" width="50" border="0">';
}
echo "</td></tr>";
}
?>
Can someone guide me with this please ?
Thanks !
Have a nice day !


Reply With Quote

Bookmarks