"image/bmp", "gif" => "image/gif", "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "jpe" => "image/jpeg", "png" => "image/png" ); //This is to final the total amount of images in the list //So we can get a random one later ;) $image_max = count($image_explode) - 1; //This is the array entry we are using $image_using_raw = rand(0,$image_max); //Let's get the string value of the image we are using //rtrim'ing so we get rid of all whitespace $image_using = rtrim($image_explode[$image_using_raw]); $image_using_size = @filesize($image_using); if (!$image_using_size) { $image_using_size = 1024; } //This is so we have the actual filename ya know like moo.jpg $image_using_name_array = explode("/", $image_using); $image_using_name = $image_using_name_array[count($image_using_name_array) - 1]; //Okay now that we have a valid image.. //But first we need to find the appropriate filetype $type_array = explode(".", $image_using); //Let's find the last array entry, which would be the file extension $type_ext = $type_array[count($type_array) - 1]; $file_type = $mime[$type_ext]; //if the file type isn't in our little mime db above //let's guess it. if (!$file_type) { $file_type = "image/" . $type_ext; } header("Content-type: $file_type"); header('Content-Disposition: inline; filename="'.$image_using_name.'"'); header('Content-Length: ' . $image_using_size); header("Cache-Control: no-cache, must-revalidate, no-store"); //Let's spit out the image! readfile($image_using); //we're done ?>