Jump to content

Archived

This topic is now archived and is closed to further replies.

perezf

Loading Images

Recommended Posts

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???

Share this post


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

[code]
    $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.";
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.