Re: getting directory info

From: Date: Tue, 27 Aug 2002 21:48:49 +0000
Subject: Re: getting directory info
Groups: php.general 
Request: Send a blank email to php-general+get-114289@lists.php.net to get a copy of this message
>Can I use php to get a list of all the jpgs in a folder? I want to make a >photo album type thing for a website, and I want it to be real simple (i.e. >you put photos (jpgs) in a folder called photos and upload them. Then the >album is built dynamically using php. Thoughts? http://php.net/opendir http://php.net/readdir http://php.net/stristr <?php $path = '/full/path/to/your/jpeg/dir/'; # Be sure it's world-readable! $dir = opendir($path) or die("Could not open $dir"); while ($file = readdir($dir)){ if (stristr($file, 'jpg') || stristr($file, 'jpeg')){ echo "<A HREF=$file>$file</A><BR>\n"; } } ?> -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#114289) next »