I am trying to upload two different files, an image and a pdf file, each from a different input as follows:
<div class="form-group" ng-class="libraries.error.img[0] ? 'has-error' : ''">
<label for="img">Image</label>
<input type="file" accept="image/*" ngf-select="" ngf-multiple="true" class="form-control" id="img" name="img" placeholder="Image" ng-model="libraries.library.img">
<p ng-if="libraries.error.img[0]" style="color: red">{{libraries.error.img[0]}}</p>
</div>
<div class="form-group" ng-class="libraries.error.document[0] ? 'has-error' : ''">
<label for="document">Document</label>
<input type="file" accept="application/pdf" ngf-select="" class="form-control" id="document" name="document" placeholder="Document" ng-model="libraries.library.document">
<p ng-if="libraries.error.document[0]" style="color: red">{{libraries.error.document[0]}}</p>
</div>
In the services file, I am sending it using the following:
store: function (library) {
console.log(library);
return Upload.upload({
url: 'api/libraries',
method: 'POST',
fields: {name: library.name, location: library.location},
file: [library.img, library.document]
});
},
But when I try to fetch the files at the server side as follows:
return $_FILES;
I keep getting:
[] No Properties
However when I change file to
file: library.img
meaning, I pass only one file, it works.
I am using ng-file-upload
with AngularJS
and the server side is Laravel
Any idea to solve this issue allowing both files to be sent to the server?!