I am using the Amazon S3 API to upload files and I am changing the name of the file each time I upload.
So for example:
Dog.png > 3Sf5f.png
Now I got
Untested, but simple enough to work:
$ext = pathinfo($filename, PATHINFO_EXTENSION);
will return the extension part (without the '.')