Any server script to count no. of images in a folder?

Hi ! all

I just want to count how many images in a folder.

Can anyone give me such .asp, php or any script, which can count no. of image in a folder, so that i can call that value to flash.

For now, i m doing this with the text file, but i manually have to enter a value for no. of images in that text file. Instead of that, I want that my script should count no. images in that folder.

Plz, help me in this…

why dont u just have a .txt that specifies that? its waaaaaaay easier that way for me

Thanks for Reply,

But u did not get my question well. my client will upload few images in a folder, with a script i want a value that no. of images are there.

As per that value I will have animation in flash.

So that i require a script to count automatically, I dont want a text file in which he has to enter the value for no. of images.

If, possible plz. give me the solution.

here’s one in php. it returns an array with each file name as a string. anything starting with ‘.’ is ignored.


function dir_to_array($d){
	$a = array();
	if(@$handle = opendir($d)) {
		while (($file = readdir($handle)) !== false) {
			if(!preg_match("/^\./",$file)) $a[] = $file;
		};
		closedir($handle); 
		return $a;
	};
	return false;
};