• support@answerspoint.com

How to list all files and folders in directory using PHP

2601

How to list-display all types files and folders in Specified directory using PHP

  • PHP

  • asked 7 years ago
  • Sandy Hook

2Answer


0

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

0

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

    Facebook Share        
       
  • asked 7 years ago
  • viewed 2601 times
  • active 7 years ago

Best Rated Questions