note 68903 deleted from function.scandir by felipe
| From: | felipe@php.net | Date: | Fri, 29 Aug 2008 23:25:17 +0000 |
| Subject: | note 68903 deleted from function.scandir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144001@lists.php.net to get a copy of this message | ||
Note Submitter: phpfeedback dot e dot stevegs at spamgourmet dot com
----
Perhaps I'm missing something, but none of the other suggestions shown here did what I wanted.
The problem was I wanted to list all files on a hidden (ie. unreferenced) directory on my web site.
Normally, if there's no INDEX.HTM, this will happen automatically. However, my service
provider is a bit smarter: they throw up an 'unauthorised user' message in the absence of
the INDEX.HTM. The following got round the problem - if the directory contents alter, the changes
are shown automatically.
Sorry about the HTML tags below - it was the only way I could get the preview to display properly.
Two files are required:
1) a blank INDEX.HTM that calls LISTFILE.PHP in a single frame:
<HTML>
<HEAD>
</HEAD>
<FRAMESET ROWS="100%" FRAMEBORDER=no BORDER=0 FRAMESPACING="0">
<FRAME src="listfile.php">
</FRAMESET></HTML>
2) a LISTFILE.PHP that lists all files and subdirectories in the current web directory (*except* the
INDEX.HTM and LISTFILE.PHP files, which you know are there!)
Links to all these files are automatically created:
<HTML>
<HEAD>
</HEAD>
<BODY>
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file !=
"index.htm"
&& $file != "listfile.php")
echo "<a href=\"$file\">$file</a><br>";
}
closedir($handle);
}
?>
</BODY></HTML>
Regards,
Steve Glennie-Smith