Click to See Complete Forum and Search --> : Outting Directory with linkage! :(


Jicksta
12-04-2003, 04:11 PM
I'm running an Apache 2.0.48 webserver and when I view a directory in a browser (Opera/Firebird/IE/IE on OSX) the directory listing is incomplete.

I'm trying to find a program to create a listing of all the files in a directory and output them as an HTML file (with links to each file). If anyone knows of a program/method of doing this, I'd really appreciate the help.


Danke,


Jay

pyro
12-05-2003, 09:37 AM
You'll need to use a server-side script to do this. Here's one in PHP:

<?PHP
$directory = "/foo"; #leave blank to display the root directory
$root = $_SERVER["DOCUMENT_ROOT"];
$path = $root.$directory;
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if (!preg_match("/^\\.*$/", $file)) {
if (is_dir(stripslashes($path."/".$file))) {
echo "<strong>$file</strong><br>"; #directory
}
else {
echo "$file<br>"; #file
}
}
}
closedir($handle);
?>

ray326
12-05-2003, 09:54 AM
Look in your Apache configuration file. There is a section where you define various attributes of the "fancy" indexing, including a filter set for names that should not be included in the index.

pyro
12-05-2003, 10:15 AM
Yeah, I actually meant to say something about just fixing it in Apache... lol

That probably would be the best way... ;)