Imatge Recent

PHP: Mostra la darrera imatge pujada en un directori
 
<?php
   $newest = -1;
   $fn = "";
   clearstatcache();
   foreach(glob("images/*.jpg") as $filename) {
      if(filemtime($filename) > $newest) {
         $newest = filemtime($filename);
         $fn = $filename;
      }
   }
echo "<img src='$fn'  width='320px' height='240px' />";
?>