Using the below PHP code snippet you would be able to list all files and folders in a directory.
Syntax
1
2
3
|
<?php
list_files("images/"); //This will list all files of images folder
?>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
function list_files($dir)
{
if(is_dir($dir))
{
if($handle = opendir($dir))
{
while(($file = readdir($handle)) !== false)
{
if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)
{
echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n";
}
}
closedir($handle);
}
}
}
|
1
2
3
|
<?php
list_files("images/"); //This will list all files of images folder
?>
|
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment