Re: Directory Listing Problem
| From: | Chronos | Date: | Tue, 03 Oct 2000 08:50:37 +0000 |
| Subject: | Re: Directory Listing Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18386@lists.php.net to get a copy of this message | ||
try this
<PRE>
<?
<? $code = "\$dir = dir(\".\");
while(\$file = \$dir->read()) {
echo \"\$file<BR>\";
}
\$dir->close();
";
echo HTMLSpecialChars($code);
echo "?>";
?>
</PRE>
<P>Output:
<PRE>
<?eval($code);?>
</PRE>
----- Original Message -----
From: "Samantha Savvakis" <samantha@cfs.net.au>
To: "PHP General" <php-general@lists.php.net>
Sent: Tuesday, October 03, 2000 1:42 AM
Subject: [PHP] Directory Listing Problem
> Hi,
>
> I have run into a slight problem using the directory functions in PHP.
>
> Versions:
> * Apache/1.3.11 Ben-SSL/1.38 (Unix)
> * PHP/4.0.3-dev
>
> I have copied the details straight from the PHP Manual:
>
> <?php
> $handle=opendir('/tmp');
> echo "Directory handle: $handle<BR>\n";
> echo "Files:<BR>\n";
> while (($file = readdir($handle))!==false) {
> echo "$file\n";
> }
> closedir($handle);
> ?>
>
> I get the following output:
> ************
> Directory handle: Resource id #1
> Files:
> ************
>
> No files are being displayed.
>
> Then I tried the "dir" class method.
>
> Again, code straight from the PHP manual:
>
> $d = dir("/tmp");
> echo "Handle: ".$d->handle."<br>\n";
> echo "Path: ".$d->path."<br>\n";
> while($entry=$d->read()) {
> echo $entry."<br>\n";
> }
> $d->close();
>
> Output:
>
> ***************
> Handle: :Resource id #1
> Path: /tmp
> ***************
>
> Again, no files listed.
>
> I have checked permissions on the directory. The apache user definitely
has
> "read" access to the /tmp directory.
> Is there some sort of setting in the apache conf file that I need?
>
> Thanks,
> Sam
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>