I want to implement file upload in my web application, I use angular.js on the client side and spring mvc on the server side.
I was able to upload a single file and upload multiple files using https://github.com/danialfarid/angular-file-upload . The fact is that when I upload several files, each of them comes to me as a separate request (which is an obvious event after the reading example code):
//inject angular file upload directives and service. angular.module('myApp', ['angularFileUpload']); var MyCtrl = [ '$scope', '$upload', function($scope, $upload) { $scope.onFileSelect = function($files) { //$files: an array of files selected, each file has name, size, and type. for (var i = 0; i < $files.length; i++) { var $file = $files[i]; $scope.upload = $upload.upload({ url: 'server/upload/url', //upload.PHP , node.js route, or servlet url // method: POST or PUT, // headers: {'headerKey': 'headerValue'}, withCredential: true, data: {myObj: $scope.myModelObj}, file: $file, //(optional) set 'Content-Desposition' formData name for file //fileFormDataName: myFile, progress: function(evt) { console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total)); } }).success(function(data, status, headers, config) { // file is uploaded successfully console.log(data); }) //.error(...).then(...); } } }];
there is an iteration over all files.
Now I am wondering if it is possible to somehow upload multiple files as one, one request.
Andna source share