title: I have an error when upload file to aws s3 bucket by using php
body: <pre><code>&lt;?php
  
  require_once(APPPATH.'libraries/REST_Controller.php');
  
  require 'vendor/autoload.php';
  
  use Aws\S3\S3Client;
  use Aws\S3\Exception\S3Exception;
  
      $s3_config = array(
          'key' =&gt; '*************',
          'secret' =&gt; '*****************************');
  
      $s3 = S3Client::factory([
              'credentials' =&gt; [
                  'key' =&gt; $s3_config['key'],
                  'secret' =&gt; $s3_config['secret'],],
              'region' =&gt; 'ap-northeast-2',
              'version' =&gt; 'latest']);
  
      function uploadS3($bucket, $dir, $file) {
  
          $key = md5(uniqid());
          $type = mime_content_type($file['tmp_name']);
          $ext = explode('/', $type);
          $ext = $ext[sizeof($ext) - 1];
          $file_name = "{$key}.{$ext}";
          $file_path = "./files/{$file_name}";
  
          move_uploaded_file($file['tmp_name'], $file_path);
  
          $save_path = null;
  
          try {
  
              $result = $GLOBALS['s3']-&gt;putObject([
                  'Bucket' =&gt; $bucket,
                  'Key' =&gt; "{$dir}/{$file_name}",
                  'Body' =&gt; fopen($file_path, 'rb'),
                  'ACL' =&gt; 'public-read']);
              $save_path = $result['ObjectURL'];
          } catch (S3Exception $e) {
              // return null;
          }
  
          unlink($file_path);
  
          return $save_path;
      }
  
  ?&gt;
  </code></pre>
  
  <p>This is my code
  I have key and secret also.</p>
  
  <p>I make this and try to upload Image File.</p>
  
  <pre><code>if (isset($_FILES['ImageOneAdd'])) {
  
              $ImageOneAdd = uploadS3('testbucket','image',$_FILES['ImageOneAdd']);
  
          }
  </code></pre>
  
  <p>but in postman, that returns this.</p>
  
  <pre><code>{
    "status": false,
    "error": {
      "classname": "InvalidArgumentException",
      "message": "Found 1 error while validating the input provided for the PutObject operation:\n[Body] must be an fopen resource, a GuzzleHttp\\Stream\\StreamInterface object, or something that can be cast to a string. Found bool(false)"
    }
  }
  </code></pre>
  
  <p>I don't know why this problems occur.</p>
  
  <p>I just do it with aws s3 upload php API;</p>
  
  <p>If anyone look at this code, and any wrong for that, please help me</p>
  
  <hr>
  
  <p>yes I chagne this code,</p>
  
  <pre><code>try {
  
              $result = $GLOBALS['s3']-&gt;putObject([
                  'Bucket' =&gt; $bucket,
                  'Key' =&gt; "{$dir}/{$file_name}",
                  'SourceFile' =&gt; $file_path,
                  'ACL' =&gt; 'public-read']);
              $save_path = $result['ObjectURL'];
          } catch (S3Exception $e) {
              // return null;
          }
  </code></pre>
  
  <p>but it occurs error with this.</p>
  
  <pre><code>{
    "status": false,
    "error": {
      "classname": "RuntimeException",
      "message": "Unable to open ./files/40c0a29b0599204c147745116554af59.jpeg using mode r: fopen(./files/40c0a29b0599204c147745116554af59.jpeg): failed to open stream: No such file or directory"
    }
  }
  </code></pre>