Counting files in a directory and passing the count back to flash

Hi there,

Im trying to create a fully automated photo gallery - where my client only needs to upload image (jpg) to a ftp server and Flash / php takes care of the rest.

I´ve found a almost completely automated gallery that only needs to be told how many files it should read from a given directory. How do I make Flash and php read the number of files in a directory and pass that variable back to flash?

The gallery i want to use is located here:

ANY help will be greatly accepted…