Laravel $request->file() returns null : <p>having trouble trying to upload files using Laravel on the back-end.</p>

<h3>Issue</h3>

<p>Laravel <code>$request-&gt;file()</code> method returns null.</p>

<h3>Setup</h3>

<p>I build up an AJAX request using <a href="https://github.com/visionmedia/superagent" rel="noreferrer">superagent</a>, debugged the request and everything seems fine. The <code>Content-Length</code> changes depending on the image I add, indicating an image has been added to the request. The <code>Content-Type</code> is also set to <code>multipart/form-data</code>.</p>

<pre><code>// request headers
Content-Length:978599
Content-Type:multipart/form-data; 

// request payload
Content-Disposition: form-data; name="files"; filename="item-keymoment.png"
Content-Type: image/png
</code></pre>

<p>But I'm unable to get the file in Laravel. Using <code>$request-&gt;file('files')</code> returns <code>NULL</code>, but if I debug the <code>$_FILES</code> array, I noticed that a my file has been uploaded.</p>

<pre><code>dd($request-&gt;file('files'))
// NULL

dd($_FILES);
// array:1 [
//   "files" =&gt; array:5 [
//     "name" =&gt; "item-keymoment.png"
//     "type" =&gt; "image/png"
//     "tmp_name" =&gt; "/tmp/phpipbeeM"
//     "error" =&gt; 0
//     "size" =&gt; 978274
//   ]
// ]

dd($request-&gt;files-&gt;all())
// []
</code></pre>

<p>What might be causing Laravel to ignore the file?<br/>
<code>Content-Type</code> of the input file not being <code>application/octet-stream</code>?</p>

<p><strong>Below have answered the question.</strong></p>
