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
You need to first find out what the original extension is and not rename the entire file. So keep the extension and rename de file name.
Assuming you have image name in $image_name:
$image_name = "image.png";
$random_string = "random";
list($filename,$fileext) = explode(".",$image_name);
$new_name = $random_string.'.'.$fileext;
rename($image_name,$new_name);