I am new in programming.
I would appreciate some help.
I have a folder in my site where I save all images from snagit.
But instead of seeing file names, I would like to see the images themselves with the last ones uploaded on top.
Could you modify the file?
Thanks.
HTML Code:
<body><?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<LI>
<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
}
?><P>List of files:</p><UL><P><?=$thelist?></p></UL></body>
I would use glob() to get an array of all the image files, then use usort() in combination with file_mtime() to sort them by date, then finally do a foreach() loop on the sorted array for the HTML output, creating <img> tags instead of <a> tags (or wrapped by the <a> tags if you want the images to be links, too).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks