View Full Version : Listing contents of a directory?
CuteEvil
February 6th, 2003, 16:04
How can I allow all users to see all the files in a particular directory? and if its possible to password protect that directory?
Kaliber
February 6th, 2003, 18:40
$handle=readdir($dir);
foreach($handle as $var) {
print "<a href=\"$var\">$var</a>";
}
Not quite sure if that works but give it a go
Cagez
February 6th, 2003, 20:35
<?php
$handle = opendir("yourdirectory");
while($file = readdir($handle)) {
echo "<a href=\"$file\">$file</a><br>";
}
closedir($handle);
?>
It would be really easy to add last accessed, last modified, file size, etc. to it also.
YUPAPA
February 6th, 2003, 22:54
Originally posted by CuteEvil
How can I allow all users to see all the files in a particular directory? and if its possible to password protect that directory?
HiHi~
put a .htaccess file to that directory
the .htaccess file must have the line below in it
Options +Indexes
If you go to the dir that you have just put the .htaccess, you should be able to see all the files!
A brief detail on how to passwd protect a dir can be found here:
http://www.webhostingtalk.com/showthread.php?threadid=109863
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.