Ok, I have a script that pulls a random image from my ./albums/ folder however... I want it to pull images from ANY subfolders in the ./ablums/ folder. Is that possible?
Heres what I have:
Code:
<?PHP
$path = './albums/';
$files=array();
if ($handle=opendir("$path")) {
while(false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
substr($file,-3)=='gif';
substr($file,-3)=='jpg';
substr($file,-3)=='jpeg';
substr($file,-3)=='png';
$files[count($files)] = $file;
}
}
}
closedir($handle);
$random=rand(0,count($files)-1);
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='jpeg') header("Content-type: image/jpeg");
elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");
readfile("$path/$files[$random]");
?>
What do I need to change?
|