简体   繁体   English

Codeigniter中的S3上传错误

[英]S3 Upload error in Codeigniter

When i upload file in s3 using CI I got the error message Message: S3::inputFile(): Unable to open input file:filename.jpg 当我使用CI在s3中上传文件时,出现错误消息Message: S3::inputFile(): Unable to open input file:filename.jpg

Here is my code 这是我的代码

$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;
 }
}

Hai I got another solution for uploading file in s3 using CI .Here i share the code .It will helpful for someone in future Hai我有另一个使用CI在s3中上传文件的解决方案。在这里我共享代码。

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

And my code : 和我的代码:

$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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM