PHP调整图像大小并上传到s3无法正常工作

I want to upload my image in amazon s3 bucket .My original image upload successfully but thumbnail not uploaded.

$name_pic = str_replace(' ', '_', trim($pic['name']));
$final_pic = time() . $name_pic;
$final_pic2 = $name_pic;

if (!defined('awsAccessKey')) define('awsAccessKey', 'AccessKey');
if (!defined('awsSecretKey')) define('awsSecretKey', 'SecretKey');

//instantiate the class
$s3 = new S3(awsAccessKey, awsSecretKey);

if ($s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic, S3::ACL_PUBLIC_READ)) {


    $new_width = 150;
    $new_height = 150;
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromstring(file_get_contents($fileTempName));
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, imagesx($image), imagesy($image));

    $s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic2, S3::ACL_PUBLIC_READ);

}

Here this line upload original image

$s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic, S3::ACL_PUBLIC_READ)

And This line should upload image after resize.But unfortunetly It also upload original image.

$s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic2, S3::ACL_PUBLIC_READ);

I do not see, at least not in the code you pasted anything assigned to to $final_pic2. The code is confusing. Where is $pic['tmp_name'] manipulated to say that there is a new image?