You can’t rename objects in S3, you have to copy them to a new object name and then delete the original
//----- SET THE FILE NAME EXTENSION TO MATCH THE USER UPLOADED FILE -----
require_once 'my_sdk_files_path/sdk.class.php'; //<<<<SET THIS
$s3 = new AmazonS3();
$bucket = "my_bucket_name"; //<<<<SET THIS
//GET THE USERS FILENAME EXTENSION
$filename_extension = pathinfo($uploaded_source_file_name, PATHINFO_EXTENSION);
//COPY THE FILE ADDING THE FILENAME EXTENSION TO THE DESTIANTION FILENAME
$s3_result = $s3->copy_object(
array( 'bucket' => $bucket, 'filename' => $uploaded_dest_file_name ),
array( 'bucket' => $bucket, 'filename' => $uploaded_dest_file_name . '.' . $filename_extension )
);
echo "<br />Worked: ";
var_dump($s3_result->isOK()); //Did it work?
echo "<br />Status: ";
var_dump($s3_result->status); //HTTP status
//DELETE THE ORIGINAL FILE
echo "<br />Deleting original file";
$s3_result = $s3->delete_object($bucket, $uploaded_dest_file_name);
echo "<br />Worked: "; //Did it work?
var_dump($s3_result->isOK());
echo "<br />Status: "; //HTTP status
var_dump($s3_result->status);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.