This one time, at band camp, V Dub <[EMAIL PROTECTED]> wrote: > Tom! > > Here's one way: >
or you could do something like this... Simply set the image directory and fire it up <?php // just so we know it is broken error_reporting(E_ALL); // set the images directory $imgDir = './images'; // open the image dir $dir = opendir("$imgDir"); // read the files in the image dir while (false !== ($file = readdir($dir))) { // make sure only image files are selected $t = @getimagesize($imgDir.'/'.$file); if ($file != "." && $file != ".." && $t['2'] < 15 && !is_dir($imgDir.'/'.$file)) { // put the file names in an array $file_array[] = $file; } } // close the dir closedir($dir); // make sure there are files in the array :/ if(!isset($file_array)) { echo 'No image files found'; } else { // shuffle the array shuffle($file_array); // pick one off the top $randImg = $file_array['0']; // get the file info $size = getimagesize ($imgDir.'/'.$randImg); // open the file for reading $fp=@fopen($imgDir.'/'.$randImg, "rb"); // if everything is cool... if ($size && $fp) { // set the headers header("Content-type: {$size['mime']}"); // show the image fpassthru($fp); // bail out exit; } else { // show an error echo 'Sorry, No images available in '. $imgDir; } } ?> or something like that, someone is bound to show some mistakes in here but it works Kevin -- ______ (_____ \ _____) ) ____ ____ ____ ____ | ____/ / _ ) / _ | / ___) / _ ) | | ( (/ / ( ( | |( (___ ( (/ / |_| \____) \_||_| \____) \____) Kevin Waterson Port Macquarie, Australia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php