Forum Moderators: coopster

Message Too Old, No Replies

PHP script to list my directories and files

         

rfontaine

3:16 pm on Dec 2, 2005 (gmt 0)

10+ Year Member



I am looking for a ready made php script that will list the directories and files on my own server. Something like this:

Information
..widgets
....about-widgets.php
....pink-widgets.php
..horses
....horse-links.php
....horse-sense.php
....Speices-Of-Horse
......arabian.php
......american.php

Etc etc.

Has anyone in webmaster world found such a script?

Thank you in advance

chriswragg

4:47 pm on Dec 2, 2005 (gmt 0)

10+ Year Member



There is a PHP fuction that will do just that. scandir() [uk2.php.net] returns a list of all files in a directory into an array. You can then use a foreach statement to print each one out:

<?
$dir = "images/"; //You could add a $_GET to change the directory
$files = scandir($dir);
foreach($files as $key => $value){
echo $value; //You could add an icon in here maybe, a link to the file/directory, or a link to list files in that directory
}
?>

Chris

chriswragg

4:51 pm on Dec 2, 2005 (gmt 0)

10+ Year Member



This script may also be useful if you want a ready made script. Webadmin [wacker-welt.de]