• support@answerspoint.com

How to list all files and folders in directory using PHP

515

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

  • PHP

  • asked 1 year 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 1 year 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 1 year ago
  • Community  wiki

Your Answer

    Facebook Share