I want to upload multiple files without using form tag and using angular js and i am using laravel 5.2. Below code i tried sending only 1 file it works but on multiple files it fails.
HTML Code
<input type="file" class="upload_file pull-right" multiple />
JQuery Code
$(".upload_file").change(function ()
{
if (this.files && this.files.length > 0)
{
scope.uploadFile(this.files);
}
});
AngularJs Code
scope = $scope;
$scope.uploadFile = function(files)
{
var fd = new FormData();
fd.append("file", files);
$http.post(API_URL + '/offline_upload/file/?token=' + token,fd,
{
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
})
.success(function(data)
{
alert('Done');
});
};
Laravel PHP Code
$files = $request->file('file');
Log::info(count($files));
Here the count is always 0
In angularjs instead of files if i send files[0] then only 1 file is sent. But how to send multiple files and retrieve it.
Can someone please help me solve this issue.