duanniwu7730 2015-02-09 06:03
浏览 55

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);
  • 写回答

1条回答 默认 最新

  • doutu1889 2015-02-09 06:10
    关注

    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?

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测