Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP调整图像大小并上载到s3不工作_Php_Image_File Upload_Amazon Web Services_Amazon S3 - Fatal编程技术网

PHP调整图像大小并上载到s3不工作

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

我想在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('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']在哪里被操纵来表示有一个新图像