title: Laravel multiple file upload
body: <p>I am trying to upload files (they can be any type), and I have a problem uploading file with certain way.</p>
  
  <p>I am able to upload a file correctly using <code>$request-&gt;file('file_name')</code> and <code>Storage::disk($disk)-&gt;put($path, $file);</code>. However, <code>$file</code> parameter can only be through <code>$request-&gt;file('file_name')</code>. </p>
  
  <p>However, because of the way I want to upload multiple orders with multiple files like below: </p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>foreach ( $filesArray as $key =&gt; $files ) {
  
      $path = 'order/'.$order-&gt;id;
  
      if ( isset($files[$i]) &amp;&amp; !empty($files[$i]) ) {
          for ( $j = 0; $j &lt; count($files[$i]); $j++ ) {
              $uploadedFile = FileHelper::upload($files[$i][$j], $path);
  
              $orderFile = [];
              $orderFile['order_id'] = $order-&gt;id;
              $orderFile['file_id'] = $uploadedFile-&gt;id;
              OrderFileModel::create($orderFile);
          }
     }
  }
  </code></pre>
  
  <p><strong>FileHelper</strong></p>
  
  <pre><code>static public function upload($file, $path, $disk = 's3')
  {
      $fileOrm = new FileModel;
      $fileOrm-&gt;size = $file-&gt;getSize();
      $fileOrm-&gt;extension = $file-&gt;getExtension();
      $fileOrm-&gt;bucket_name = self::$BUCKET_NAME;
      $fileOrm-&gt;type = self::getFileType($file-&gt;getExtension());
      $fileOrm-&gt;key = Storage::disk($disk)-&gt;put($path, $file);
      $fileOrm-&gt;created_time = now();
      $fileOrm-&gt;save();
  
      return $fileOrm;
  }
  </code></pre>
  
  <p>I've also attached images where I see the difference.
  One with <code>$request-&gt;file('file_name')</code> and the other with just <code>$request-&gt;file_name</code> which is blob type.</p>
  
  <p><a href="https://i.stack.imgur.com/er2kD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/er2kD.png" alt="able to upload"></a></p>
  
  <p><a href="https://i.stack.imgur.com/hQ4BO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hQ4BO.png" alt="not able to upload: with error fstat() expects parameter 1 to be resource, object given"></a></p>
  
  <p>The image below would return error saying <code>fstat() expects parameter 1 to be resource, object given</code></p>
  
  <p>How could I solve this problem?</p>
  
  <p>Any advice or suggestion would be appreciated. Thank you.</p>