PHP调整图像大小并上载到s3不工作
我想在amazon s3 bucket中上载我的图像。我的原始图像上载成功,但缩略图未上载PHP调整图像大小并上载到s3不工作,php,image,file-upload,amazon-web-services,amazon-s3,Php,Image,File Upload,Amazon Web Services,Amazon S3,我想在amazon s3 bucket中上载我的图像。我的原始图像上载成功,但缩略图未上载 $name_pic = str_replace(' ', '_', trim($pic['name'])); $final_pic = time() . $name_pic; $final_pic2 = $name_pic; if (!defined('awsAccessKey')) define('awsAccessKey', 'AccessKey'); if (!defined('awsSecret
$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);
}
这里这行上传原始图像
$s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic, S3::ACL_PUBLIC_READ)
这行应该在调整大小后上传图像。但不幸的是,它也上传原始图像
$s3->putObjectFile($pic['tmp_name'], "bucketname", $final_pic2, S3::ACL_PUBLIC_READ);
我没有看到,至少在您粘贴到$final_pic2的任何内容的代码中没有看到。代码令人困惑。$pic['tmp_name']在哪里被操纵来表示有一个新图像