How to count no of Files in a Folder?

if (file_exists("images/"))
{
 $dh = opendir("images/");
 $filecount = 0;
 while (($file = readdir($dh)) !== false) 
 {
  if(is_file("images/".$file))
   $filecount++;
 }
 echo 'No fo Files is: '.$filecount;
}

$directory = "../images/team/harry/";
if (glob($directory . "*.jpg") != false)
{
 $filecount = count(glob($directory . "*.jpg"));
 echo $filecount;
}
else
{
 echo 0;
}

0 comments:

Post a Comment