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
I think something as simple as below should work to extract file extension from the file-name:
function getFileExtension($fileName) { $ext = ''; if(strpos($fileName, ".") !== false) { $ext = end(explode(".", $fileName)); } return $ext; }