Jump to content


Photo

Loading Images


  • Please log in to reply
1 reply to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 23 May 2006 - 03:15 AM

I need a way to list all images in a specific folder specified
but i cant figure out how to do it
can someone help me out???


#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 May 2006 - 04:09 AM

Hope this is what you're looking for -- just some simple code I use to display images in the current folder.

    $dir = realpath("."); //current folder. Can change the "." to "somefolder"
    if (is_dir($dir)) {
        if($dh=opendir($dir)) {
            while(($file=readdir($dh))!=false) {
                if(substr($file,0,1)!=".")     echo "<img src=\"".$file."\"><br>".$file."<br><br>\n";
            }
            closedir($dh);
        }
    } else echo "Folder error. Try using ".realpath(".")." as a starting point.";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users