Reply
Random images from more than 1 directory
Old 10-26-2004, 01:22 PM Random images from more than 1 directory
DKasler's Avatar
Skilled Talker

Posts: 83
Location: Brooklyn
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?
DKasler is offline
Reply With Quote
View Public Profile Visit DKasler's homepage!
 
When You Register, These Ads Go Away!
Old 10-26-2004, 02:55 PM
DKasler's Avatar
Skilled Talker

Posts: 83
Location: Brooklyn
Thanks anyway. I got it all worked out.
DKasler is offline
Reply With Quote
View Public Profile Visit DKasler's homepage!
 
Reply     « Reply to Random images from more than 1 directory
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10249 seconds with 12 queries