Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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 Codeigniter中的S3上载错误_Php_Codeigniter_Amazon S3 - Fatal编程技术网

Php Codeigniter中的S3上载错误

Php Codeigniter中的S3上载错误,php,codeigniter,amazon-s3,Php,Codeigniter,Amazon S3,当我使用CI在s3中上载文件时,收到错误消息消息:s3::inputFile():无法打开输入文件:filename.jpg 这是我的密码 $time = Time(); if(!empty($_FILES['productImage']['name'])){ $file_name = $_FILES['productImage']['name']; $productImageName = 'PRD_'.$time.$_FILES['productImage']['name'];

当我使用CI在s3中上载文件时,收到错误消息
消息:s3::inputFile():无法打开输入文件: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;
 }
}

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

来自github的代码:

我的代码是:

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