Script for dispalying folder contents (with links) when the file list has been disabled

On an appache server with the file listing ability turned off, I'd like to create an index.htm file that contains a script that would list the files in the folder.  Is this possible?  Can the file list have links to the files listed?

Thanks!
leslieinvaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
> I'd like to create an index.htm file that contains a script that would list the files in the folder.  Is this possible?

Yes, if you have a script behind it which reads the content of the folder and generates a html page. But that script has nothing to do with apache. I'd suggest that you ask in the community support TA to move the question to the PHP or CGI Programming TA depending upon the script language you choose.

Your DirectoryIndex directive might look like

DirectoryIndex /cgi-bin/showindex.pl
0
yfedchunCommented:
Here's a great PHP script that does this.  Just save this as index.php, upload and run!

<?
function dir_list($dir)
{
$i=0;
  $dl = array();
  if ($hd = opendir($dir))
  {
    while ($sz = readdir($hd)) { if (preg_match("/^\./",$sz)==0) $dl[] = $sz;$i.=1; }
    closedir($hd);
  }
  asort($dl);
  return $dl;
}

?>

<body bgcolor="#FFFFFF" text="#000000"><table width="550" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td width="133"><img src="http://10.0.0.1/~yasha/me.jpg" ></td>
    <td valign="top"><b><? echo $msg ?></b><br><? echo $today;
?><br><b>Thought of the moment:</b><br><? echo $ts; ?></td>
  </tr>
</table>
<br><hr widht="80%">
<?

$directory = dir("./");
print "<b>Path:</b><font color=\"blue\">".$directory->path."</font><br>";
print "<b>Files:</b><br>";

while($file=$directory->read())
{
print "<font color=\"blue\"><a href=$file>$file</a><br>";
}

$directory->close();

?>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.