Php
<?php
$sdir = array();
$files = scandir(__DIR__ . '/img');
foreach ($files as $i => $entry) {
if ($entry != '.' && $entry != '..' && fnmatch('*.jpg', $entry)) $sdir[] = $entry;
}
$img_nom = (int) $_SESSION['img_nom'];
$link = $sdir[$img_nom];
$_SESSION['img_nom'] = ($img_nom == count($sdir) - 1) ? 0 : $img_nom + 1;
?>
<img src="/img/<?php echo $link;?>">