Take the 2-minute tour ×

I currently have a very simple intranet that we are using for some basic company documentation. The site has a navigation bar across the top of the page that has drop down lists containing links to all the documents.

At present, if someone needs to add a new document, I have to manually go in and create a list item with the link to that document, in order for it to be added to the drop down.

Is there is a way I can save myself a job, using a script that can auto create these list items based on the folder contents?

If there is a PHP option, this would be ideal as this is what I am most familiar with.

share|improve this question
Yes, it's possible. The easiest thing would be just use PHP to get a list of all the files in the directory/directories where the documents are stored and automatically output a list. It would always be current. Are you looking for an example or can you handle it? –  rdlowrey Dec 16 '11 at 16:24
php.net/manual/en/ref.filesystem.php –  djot Dec 16 '11 at 16:24
thanks guys, hopefully i've got it –  Eds Dec 16 '11 at 16:56

1 Answer 1

up vote 3 down vote accepted

Using glob() you can easily get a list of files in a directory and output them:

$doc_dir = '/path/to/docs';
foreach(glob("$doc_dir/*") as $file) {
  echo "<li><a href='$doc_dir/$file'>$file</a></li>", PHP_EOL;
share|improve this answer
this is excellent, should be able to work this in to my system! thanks very much! –  Eds Dec 16 '11 at 16:55

Your Answer


