<? php header('Content-type: image/jpg'); $hd = opendir('photo'); while($file = readdir($hd)) if($file != '.' && $file != '..') $imgs[] = $file; echo file_get_contents('photo/' . $imgs[rand(0, sizeof($imgs)-1)]);