PDA

View Full Version : directory search



pghcollectibles
04-15-2008, 09:58 PM
is there a way to list all the file names in a folder using script. i had an idea for using ftp for my brother to upload pictures but then i wanted to add their file name info into a database to display them in a table using a query

sirbrent
04-16-2008, 05:59 PM
you could install autoindex, and just rename the access file to something other than index.php.

http://autoindex.sourceforge.net/

sirbrent
04-16-2008, 06:03 PM
or zenphoto which is available through "simple scripts" icon in cpanel. its a lightweight flexible photo manager, you can setup "albums" to be generated on the fly from specific folders.

pghcollectibles
04-16-2008, 09:47 PM
i guess i was hoping for something along the lines of like the command prompt in windows ie:

cd public_html
cd images
dir

pghcollectibles
04-16-2008, 09:48 PM
but in php or something

linFox
04-17-2008, 03:16 AM
The simplest way for a basic file listing (or to iterate over every file, etc) in PHP is to use the scandir() function. It returns an array of all the filenames in the directory.

Eg. to simply print all the filenames in /public_html/images/,

foreach (scandir($_SERVER['DOCUMENT_ROOT']."/images/") as $filename) {
if ($filename != "." && $filename != "..") {
echo $filename."\n";
}
}

pghcollectibles
04-17-2008, 06:44 AM
thank you very much