RE: [PHP] Readdir
| From: | Matt Schroebel | Date: | Thu, 01 Aug 2002 19:00:10 +0000 |
| Subject: | RE: [PHP] Readdir | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-110725@lists.php.net to get a copy of this message | ||
> From: msmecca@mindspring.com [mailto:msmecca@mindspring.com]
> Sent: Thursday, August 01, 2002 2:54 PM
> To: php-general@lists.php.net
> Subject: [PHP] Readdir
>
> New To Php so please bear with me... :)
>
> I used the readdir function to read the files listed on a
> Apache server. And
> it worked fine. Now I would like to be able to get the files
> the php code
> returns, to be links. Where the user can click the file and
> download it. Also
> for the files to sit within a table or at least look neat on the page.
> http://www.optimus7.com/findme.php is the result I get from
> the php code
> below. Help!
>
> <?php
> if ($handle = opendir('/my/directory')) {
> echo "Directory handle: $handle\n";
> echo "Files:\n";
>
>
>
> while (false !== ($file = readdir($handle))) {
> echo "$file\n";
> }
>
>
> closedir($handle);
> }
> ?>
Change your echo stmt to something like:
echo "<a href=\"$file\">$file</a><br>\n";