Dynamic flash galley with PHP?

Ok i have a flash file that contains 48 thumbnail images. Each image will load a page with the full image on it. I"m looking for some PHP code or something that will send a file variable from flash (ex. if you click image1 it will pull image1.jpg out a file) using php or somehting and pull the corosponding picture out of a file then put that picture into a template HTML page in a fixed size.

Any body seen a tutorial or something on how maybe to do this?