Forum Moderators: coopster

Message Too Old, No Replies

Directory Listing

         

HeadBut

8:59 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



How do you get a list of files in a directory?

TymArtist

9:07 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



Hello HeadBut,

What sort of directory are you referring to?
If you're referring to a database then it would be a table rather than a directory.
If you want to access a given directory on a server that contains a file that PHP should read, check out [zend.com...] for a tutorial on how to do that.

Getting a list of files from a given website involves either going to the FTP site or finding a host that gives you the option to list all the files on the site.

You could even be talking about Windows, so provide more specifics and I'll be glad to help you out further ;)

HeadBut

9:10 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



Thanks,

I mean a file listing of a directory on my local machine/hard drive. Very simple I have a folder in my php directory and I want to see what files people have put in it and I want to read them and do some analysis.

TymArtist

9:23 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



IMO that link that I posted above is probably contains the code for anything you're looking to do. The subtitle is, after all, "Everything you're ever likely to need to know about dealing with external files from a PHP script." Good luck!

HeadBut

10:04 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



Here is the snipped of code thats got me hung!
This is from the ZEND link you gave me.
Thanks

<table>
<?php
$uploadDir = '\\sun201/phptest/Files_to_Review/';

if ($handle = opendir($uploadDir)) {

while (false!== ($file = readdir($handle))) {
if ($file!= "." && $file!= "..") {
$fullpath = $uploadDir.$file;
echo "<tr><td><b><a href='$fullpath'>$file</a></b></td>";?>
<td>&nbsp;&nbsp;<a href='#' onClick="if(confirm('Are you sure you wish to delete this file?')) {
window.open('filedelete.php?path=<?php echo $fullpath;?>','UploadFile','top=30,left=30,width=350,height=150');return
true; } else { return false; }">Delete</a>
</td>
</tr>
<?php
}
}
closedir($handle);
}
?>
</table>

jatar_k

10:17 pm on Sep 23, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try these

list everything
[webmasterworld.com...]

list only jpgs
[webmasterworld.com...]