It seems to work fine
for some reason my browser downloaded the php file so I could see your code
and that code is way much more than you need. Here's some code 1/10 the size:
PHP Code:
<?php
$dir = "images/";
$allfiles = glob($dir."*");
foreach($allfiles as $k => $v){
$info = pathinfo($v);
switch($info['extension']){
case "gif":
case "png":
case "jpg":
case "jpeg":
break;
default:
array_splice($allfiles, $k, 1);
break;
}
}
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$rand = rand(0, count($allfiles)-1);
$file = $allfiles[$rand];
$info = pathinfo($file);
header('Content-Type: '.$extList[$info['extension']]);
readfile($file);
?>
Not guaranteed to work, but it's worth a try.
Bookmarks