Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically build links to documents

Status
Not open for further replies.

groovygarden

Programmer
Aug 23, 2001
63
Hiya,

My department has a server with a lot of documents stored on it - I want to create a front end to this so that users can navigate through the directories to find the document they want. This is easy enough, but the problem is the structure of the directories changes quite frequently and so I want to avoid hard coding links to directories/files. Is there a way I can read the directory structure of the server and build links dynamically whenever the site is accessed.

I hope I've explained this OK!

Any help much appreciated - thanks
 
<?php
if ($handle = opendir('/path/to/files')) {
echo &quot;Directory handle: $handle\n&quot;;
echo &quot;Files:\n&quot;;

while (false !== ($file = readdir($handle))) {
echo &quot;$file\n&quot;;
}

closedir($handle);
}
?>

Taken from:
My Work...
...and More...
 
From a command propmt in the base directory type
DIR/b *. > DIRLIST.TXT
This will produce a file DIRLIST.TXT in the base directory. Now write a program in the language of your choice reading each record in DIRLIST.TXT and building links.

HTH,
Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top