is there a function that returns the contents of a directory on your server? I need something like this to make a script where one can up a butt load of pics by ftp and run this script to make an html page that has the source for a photo album.
[code=php] <?php $dir = '/path/to/image/directory/from/root/'; //get directory contents $contents = array(); $dir = opendir($_SERVER['DOCUMENT_ROOT'] . $dir); while (false !== ($file = readdir($dir))) { $contents[] = $file; } closedir($dir); // Print file names foreach($contents as $file){ if(($file != '.') and ($file != '..')){ print ($file . '<br>'); } } ?> [/code]
[code=php] <?php $dir = '/path/to/image/directory/from/root/'; //get directory contents $contents = array(); $dir = opendir($_SERVER['DOCUMENT_ROOT'] . $dir); while (false !== ($file = readdir($dir))) { $contents[] = $file; } closedir($dir); //get only jpeg contents $jpeg_contents = array(); foreach($contents as $file){ if (eregi('.jpg{1}$', $file)){ $jpeg_contents[] = $file; } } // display images foreach($jpeg_contents as $file){ print ('<img src="/http/path/to/directory/' . $file . '"><br>' . "n"); } ?> [/code]
[code=php] <?php $dir = '/path/to/image/directory/from/root/'; $dir = opendir($_SERVER['DOCUMENT_ROOT'] . $dir); while (false !== ($file = readdir($dir))) { if (eregi('.jpg{1}$', $file)){ print ('<img src="/http/path/to/image/directory/' . $file . '"><br>' . "n"); } } closedir($dir); ?> [/code]
Help @gameguy43 spread the word by sharing this article on Twitter...