[SOLVED] Output of a Folder?
Moderator: General Moderators
Output of a Folder?
Hi,
I have a fodler on my webserver, /www/*foldername*/
How would I make an output so that you can view all the files of that folder?
IE - If I just have the files in a root folder, and go to that folder manually, Apache will list the files with their type, size, etc.
Any help would be greatly appreciated....
Thanks, th3gh05t
I have a fodler on my webserver, /www/*foldername*/
How would I make an output so that you can view all the files of that folder?
IE - If I just have the files in a root folder, and go to that folder manually, Apache will list the files with their type, size, etc.
Any help would be greatly appreciated....
Thanks, th3gh05t
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
Or do a index.php with:
i dont test it.
http://www.php.net/manual/en/function.is-file.php
Code: Select all
<?php
$rep=opendir('.');
while ($file = readdir($rep)){
if($file != '..' && $file !='.' && $file !=''){
if (is_file($file)){
echo $file;
}
}
}
closedir($rep);
?>http://www.php.net/manual/en/function.is-file.php
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
yes its posible changing the script y put there...
buy, if you only want it like apache the easy way is using .htaccess (feyd) try google: http://www.google.com/search?hl=en&lr=& ... tnG=Search
buy, if you only want it like apache the easy way is using .htaccess (feyd) try google: http://www.google.com/search?hl=en&lr=& ... tnG=Search
Thanks for all your help!
This is the final code that works for me..
This is the final code that works for me..
Code: Select all
<?
//Set Directory
$dirname = "files";
//Open dir into file handle
$dh = opendir($dirname) or die("error opening directory...");
//Loop through each file in the dir
while(!(($file=readdir($dh))===false)) {
if ($file == "." || $file == ".." || $file == "index.php")
{
}
else{
//Create a list with links
echo "<a href='".$file."'>".$file."</a><br>";
}
}
//Close the file handle
closedir($dh);
?>