title: Laravel file upload API using Postman
body: <p>I have the following code in my controller: </p>
  
  <pre><code>    public function upload(Request $request)
      {
         $files = $request-&gt;file('uploads');
         if(!empty($files)) {
             foreach($files as $file) {
                 Storage::put($file-getClientOriginalName(),file_get_contents($file));
          }
      }
  </code></pre>
  
  <p>Which is called via an <code>api.php</code> in <code>routes</code>: </p>
  
  <pre><code>Route::post('/upload', [ 'uses' =&gt; 'UploadController@upload' ]);
  </code></pre>
  
  <p>I am using postman to test my application.</p>
  
  <p><strong>Header:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FDjC4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FDjC4.png" alt="enter image description here"></a></p>
  
  <p><strong>Body:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/MPikD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MPikD.png" alt="enter image description here"></a></p>
  
  <p><strong>Raw:</strong></p>
  
  <blockquote>
    <p>POST /scotic/public/api/upload HTTP/1.1 Host: 127.0.0.1:80
    Content-Type: multipart/form-data;
    boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW Cache-Control: no-cache
    Postman-Token: 0caf7349-5c91-e5f1-766f-72a3f1e33900</p>
    
    <p>------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="uploads[]"; filename="banana.png" Content-Type:
    image/png  png data goes here..
    ------WebKitFormBoundary7MA4YWxkTrZu0gW--</p>
  </blockquote>
  
  <p>The <code>$files</code> is empty upon uploading the file. What am i doing wrong? </p>
  
  <p>After a bit of digging, I got my uploader working without postman, I noticed that the '--boundary' was missing from the <code>Content-Type</code> in postman. The LHS works, RHS(postman) does not work. </p>
  
  <p><a href="https://i.stack.imgur.com/vypP7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vypP7.png" alt="enter image description here"></a></p>
  
  <p>Any ideas? </p>