Page 1 of 1
simple script question
Posted: Wed Jun 05, 2002 11:13 pm
by Sevengraff
i know its possible, and im sure its easy, but how do i use php to list all the files in a directory and have it link to the files it lists? I looked at places like hotscripts.com but couldn't find anything. Please help.
Posted: Thu Jun 06, 2002 12:26 am
by volka
Posted: Thu Jun 06, 2002 4:10 am
by Wayne
Code: Select all
$arraycounter=0;
$DirHandle = opendir(".");
while ( $filesread = readdir($DirHandle) ) {
$filesї$arraycounter]=$filesread;
$arraycounter++;
}
closedir($DirHandle);
sort($files, SORT_STRING);
$arraycounter=0;
while ( $file = $filesї$arraycounter] ) {
$arraycounter++;
if ( ( $file != "index.htm" ) && ( $file != "style.css") ) { // remove unwanted files from list
if (!is_dir($file)) { // remove directories from list
echo "<A HREF="$file">$file</A>\n<BR>\n";
}
}
}
Posted: Thu Jun 06, 2002 7:24 am
by qads
Posted: Sat Jun 08, 2002 1:17 am
by Sevengraff
thanks!