【问题标题】:S3 Upload error in CodeigniterCodeigniter 中的 S3 上传错误
【发布时间】:2016-12-19 02:06:20
【问题描述】:

当我使用 CI 在 s3 中上传文件时,我收到错误消息 Message: S3::inputFile(): Unable to open input file:filename.jpg

这是我的代码

$time = Time();
if(!empty($_FILES['productImage']['name'])){
$file_name        =  $_FILES['productImage']['name'];
$productImageName = 'PRD_'.$time.$_FILES['productImage']['name'];
 if ($this->s3->putObjectFile($file_name, "bucketname", $productImageName, S3::ACL_PUBLIC_READ)) {
   echo "We successfully uploaded your file.";exit;
 }else{
    echo "Something went wrong while uploading your file... sorry.";exit;
 }
}

【问题讨论】:

    标签: php codeigniter amazon-s3


    【解决方案1】:

    嘿,我得到了另一种使用 CI 在 s3 中上传文件的解决方案。在这里我分享代码。这将对将来的某人有所帮助

    来自 github 的代码:https://github.com/fcosrno/aws-sdk-php-codeigniter

    还有我的代码:

    $this->load->library('aws_sdk');
    try{
       $aws_object=$this->aws_sdk->saveObject(array(
       'Bucket'      => 'mybucket',
       'Key'         => 'QA/product/'.$newImagename,
       'ACL'         => 'public-read',
       'SourceFile'  => $_FILES['productImage']['tmp_name'],
       'ContentType' => 'image/jpeg'
    ))->toArray();
    
    }catch (Exception $e){
      $error = "Something went wrong saving your file.\n".$e;
      echo $error;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-22
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多