How to get formdata values sent by ajax post method in laravel controller
<p>I am trying to send a set of data including image file through ajax using formdata but when I want to access that data in laravel controller, it shows a blank array.</p>

<p>Here is my ajax code - </p>

<pre><code>var fd = new FormData();
    fd.append("photo",files[0]);
    fd.append("user_id",localStorage.getItem('userId'));
    fd.append("doctype","dl_image");       
    console.log(fd);



   //ajax code
    $http.post('uploadfile', fd, {    
            withCredentials: true,      
            headers: { 'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content') }       
     }).success(function(data, status) {        

               console.log(data);


     });
</code></pre>

<p>PHP code -</p>

<pre><code>    $data = Request::all();
    $photo = Request::file('photo');
    $userid = Request::get('user_id');
    $doctype = Request::get('doctype');


    $postData = array(
        'photo' =&gt; $photo,
        'user_id' =&gt; $userid,
        'doctype' =&gt; $doctype  
    );
    var_dump($data);
    die();
</code></pre>

<p>When the data is dumped in browser's console, it shows</p>

<pre><code>array(0) {
}
</code></pre>

<p>Need help.</p>