Per contarle basta che usi un contatore che incrementi via via.

Codice PHP:
$path "./foto/";

$conta 0;
if (
$handle opendir($path)) 
{
   while (
false !== ($file readdir($handle))) 
    {
       if(
$file!="." && $file !="..")
       
$conta++;
    }
   
closedir($handle);
}
echo 
$conta