| View previous topic :: View next topic |
| Author |
Message |
nitromaster
Joined: Wed Feb 21, 2007 6:28 pm Posts: 32
|
Posted: Mon Jun 11, 2007 8:42 pm Post subject: How to list the contents of a folder on a web server? |
|
|
title says it all,
is this possible? |
|
| Back to top |
|
 |
M0PHP LXF regular

Joined: Wed Apr 06, 2005 8:40 am Posts: 737 Location: Bishop Auckland, County Durham, UK
|
Posted: Mon Jun 11, 2007 9:02 pm Post subject: RE: How to list the contents of a folder on a web server? |
|
|
If you have access to the server then it is fairly easy - just enable directory listings
To expand on that - if it's Apache and you do have access to the server config - just put this line in the directory configuration of the Apache config:
Or you could also add that very same line to a .htaccess file (in the directory you want listings of) if you don't have access to the server but are still allowed htaccess. _________________
 |
|
| Back to top |
|
 |
JS LXF regular
Joined: Thu Sep 13, 2007 12:27 am Posts: 116
|
Posted: Wed Oct 10, 2007 5:25 pm Post subject: RE: How to list the contents of a folder on a web server? |
|
|
Alternatively, if you can't do htaccess but have PHP, then the following would work as a simple, minimal index.php:
| Code: | <html>
<head>
<title> PHP index lister </title>
</head>
<body>
<h1> Directory listing </h1>
<?
# Change the . below to another directory name
# if you want to list the contents of a different directory
$handle = opendir('.');
if ($handle) {
while (false !== ($file = readdir($handle))) {
# The if clause below is only necessary
# if you don't want to list this file and hidden files
# (Leaving it is a good idea)
if (($file[0] != ".") and ($file != "index.php"))
{
print "<a href=\"$file\">$file</a><br />\n";
}
}
}
closedir($handle);
?>
</body>
</html>
|
I've used it (well, a slightly modified version) myself, and it works for me. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|