Tony Laubach
EF5
Hey all,
I'm coming short on my searches for a code and I was hoping to find some help here..
I've recently ventured into PHP for the first time during the updating of my site, and one thing I wanted to do was have a section that displays the latest image uploaded to a specific directory. Namely the directory to where my cell phone-sent photos go.
I've found a few close calls, but nothing which I would think would be easy.
Basically all I am trying to do is display an image on my website, but it is the latest uploaded image from a specific directory. When a new image is uploaded, the image on the page will change to that new image.
I'm fiddling with the filemtime and filectime commands, but still am coming up short.
That doesn't seem to want to post the most recently uploaded picture.
Any help would be appreciated!
I'm coming short on my searches for a code and I was hoping to find some help here..
I've recently ventured into PHP for the first time during the updating of my site, and one thing I wanted to do was have a section that displays the latest image uploaded to a specific directory. Namely the directory to where my cell phone-sent photos go.
I've found a few close calls, but nothing which I would think would be easy.
Basically all I am trying to do is display an image on my website, but it is the latest uploaded image from a specific directory. When a new image is uploaded, the image on the page will change to that new image.
I'm fiddling with the filemtime and filectime commands, but still am coming up short.
Code:
<?php
$ctime = 0;
foreach (glob('*.jpg') as $file)
{
if ($mtime > filemtime($file))
{
$match = $file;
$mtime = filemtime($file);
}
}
print '<img src="' . htmlentities($file) . '" alt="Image Title Here">';
?>
That doesn't seem to want to post the most recently uploaded picture.
Any help would be appreciated!