simple script question
Moderator: General Moderators
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
simple script question
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.
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";
}
}
}i had the same question, read
http://www.devnetwork.net/forums/viewtopic.php?t=617
http://www.devnetwork.net/forums/viewtopic.php?t=617
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact: