Having trouble uploading multiple files
<p>Can save individual files, however, with multiple it doesn't appear to get a proper array from $request->file() and foreach fails.</p>

<p>Client </p>

<pre><code>$scope.setFiles = function(element) {
    $scope.$apply(function($scope) {
      console.log('files:', element.files);
      // Turn the FileList object into an Array
        $scope.files = []
        for (var i = 0; i &lt; element.files.length; i++) {
          $scope.files.push(element.files[i])
        }
      $scope.progressVisible = false
      });
    };

    $scope.uploadFile = function() {
        var fd = new FormData()
        for (var i in $scope.files) {
            fd.append("file", $scope.files[i])
        }

        var boundary=Math.random().toString().substr(2);

        var xhr = new XMLHttpRequest()
        xhr.upload.addEventListener("progress", uploadProgress, false)
        xhr.addEventListener("load", uploadComplete, false)
        xhr.addEventListener("error", uploadFailed, false)
        xhr.addEventListener("abort", uploadCanceled, false)
        xhr.open("POST", "/fileupload",true)
        $scope.progressVisible = true
        xhr.setRequestHeader("X-CSRF-TOKEN", csrftoken);
        xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');

        // xhr.setRequestHeader("content-type","multipart/form-data; charset=utf-8; boundary=" + boundary);        
        xhr.send(fd)
    }
</code></pre>

<p>Laravel</p>

<pre><code>public function fileUpload(Request $request)
{


    $files = $request-&gt;file('file');


    $file_count = count($files);

    echo $file_count;

   foreach ($files as $file) {

        $oname = $file-&gt;getClientOriginalName();
        $filename = $oname.'.'.$file-&gt;getClientOriginalExtension();

        $file-&gt;move(
            base_path() . '/uploads/applicants/', $filename
            );

    }



}
</code></pre>