how to show No of images in directory.????????

Please help me on this… I wanna know how to show da no of images available in directory using php…
User’s keep uploading pictures so i wanna show how many images are upload in directory… so PLease help me on this…

Why do you think one question mark in the subject line of your post is not enough?

Regarding your task, you can check this function that generates array of files found in given directory and subdirectories, and see how you can adapt it for your needs.

I saw da link but i didnt not understand how to use or whr to paste it…!!!
thr r two codes… which1 whr n how to paste it… please… temme

[php]<?php
// Recursively find files in the given directory

function find_files($mydir){

global $results;

if(($tdir=@opendir($mydir))!==false){
  while($f=readdir($tdir)){
    if($f!="." and $f!=".."){
      if(is_dir($mydir."/".$f)){
        // directory found
        if(find_files($mydir."/".$f)>=1000) return count($results);
      }
      elseif(is_file($mydir."/".$f)){
        // file found
        if(count($results)>=1000) return count($results);
        $results[]=$mydir."/".$f;             
      }
    }
  }  
  closedir($tdir);
}
return count($results);

}

$results = array();
find_files(’ YOUR DIRECTORY ');

if(count($results)) foreach($results as $line) echo $line."
\n";
?>[/php]

[php]$images = count(preg_grep(’/.jpg|.png|.bmp|.gif$/’,scandir(‘pathto/imagesfolder’)));
echo ‘There are ‘.$images.’ images’;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service