Jump to content

Loading Images


perezf

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/10230-loading-images/#findComment-38141
Share on other sites

Archived

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

×
×
  • Create New...

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.