title: Request is empty when trying to upload files via AJAX in Laravel 5.2
body: <p>I'm having an issue trying to upload a file in <strong>Laravel 5.2</strong> via AJAX. I want to submit a form that contains some text fields and a file input using the <code>new FormData()</code> method, but the Request::all() seems to return an empty array in the controller.  The problem is occurring only when I try to upload an image. If I leave the file input empty, everything is fine and all the text inputs are showing. I've tried to change the AJAX call with every option possible but it's the same result. </p>
  
  <p><strong>The form:</strong></p>
  
  <pre><code>&lt;form id="my_form"&gt;
     &lt;input type="text" name="u_name" placeholder="Enter name" value="{{ $user-&gt;NAME }}"&gt; 
     &lt;input type="email" name="u_email" placeholder="Enter email" value="{{ $user-&gt;EMAIL }}"&gt;
     &lt;input type="file" name="u_picture"&gt;
     &lt;input type="submit" id="submit" value="Save"&gt;    
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>The jQuery AJAX request:</strong></p>
  
  <pre><code> $('#my_form').submit(function(){
  
      $.ajax({
          type: "POST",
          headers: {'X-CSRF-TOKEN': "{{ csrf_token() }}" },
          dataType: "json",
          url: "/submit",
          contentType: false,
          data : new FormData($('#my_form')[0]),
          processData: false,
          async: true,
          success: function(data){
            console.log(data);
          }
  
      }).fail(function(data) {
          console.log('Error');
      });
      return false;
  });
  </code></pre>
  
  <p><strong>The controller method:</strong></p>
  
  <pre><code>public function editProfile(){
     if(Request::hasFile('u_image'){
        return 'It has image';
     }
     return Request::all();
  
  }
  </code></pre>
  
  <p><strong>Output with file input empty:</strong></p>
  
  <pre><code>Object {u_name: "Test", u_email: "abc@abc.com"}
  </code></pre>
  
  <p><strong>Output with file input NOT empty:</strong></p>
  
  <pre><code>[]
  </code></pre>
  
  <p><strong>However</strong>, the request seems to be sent correctly in both cases because in network tab in google chrome the request is like this:</p>
  
  <pre><code>------WebKitFormBoundaryFZlyLOFBAsPNOk7v
  Content-Disposition: form-data; name="u_name"
  
  Test
  
  ------WebKitFormBoundaryFZlyLOFBAsPNOk7v
  Content-Disposition: form-data; name="u_email"
  
  abc@abc.com
  
  ------WebKitFormBoundaryFZlyLOFBAsPNOk7v
  Content-Disposition: form-data; name="u_picture"; filename="1.jpg"
  Content-Type: image/jpeg
  
  
  ------WebKitFormBoundaryFZlyLOFBAsPNOk7v--
  </code></pre>
  
  <p>I also tried to send the AJAX with <code>async:false</code>, but no result. Is there anything that I am doing wrong?</p>
  
  <p><strong>Edit:</strong> The problem persists even with AJAX calls from Postman</p>
  
  <p><strong>Edit 2:</strong> I isolated the problem. In my original code I'm using the method <code>Request::hasFile('u_picture')</code> to verify if the field is empty. Without that <code>if</code> statement, everything works like charm (until the form is submited without the picture, of course). So my question now is: how do I fix this?</p>