How to list all files and folders in directory using PHP
How to list-display all types files and folders in Specified directory using PHP
PHP
- asked 7 years ago
- Sandy Hook
2Answer
use this code ...... for find / list all files/ folder in directory
//path to directory to scan $directory = "folder_name/"; //get all files in specified directory $files = glob($directory . "*"); //print each file name foreach($files as $file) { //check to see if the file is a folder/directory if(is_dir($file)) { echo $file; } }
- answered 7 years ago
- Community wiki
use following code for list all files name
function listFolderFiles($dir)
{
$ffs = scandir($dir);
foreach($ffs as $ff)
{
if($ff != '.' && $ff != '..')
{
if(!is_dir($dir.'/'.$ff))
{
$file_name=$ff;
echo ",'$file_name'";
}
}
}
}
- answered 7 years ago
- Community wiki
Your Answer