<?php $file = glob("papka/*"); $randimg = $file[array_rand($file)]; echo '<a href="'.$randimg.'"><img src="'.$randimg.'" alt="" /></a>';