nervgh / angular-file-upload

[ALMOST NOT MAINTAINED] Angular File Upload is a module for the AngularJS framework
MIT License
3.44k stars 1.13k forks source link

angular1 single item does not add formdata #887

Closed gabrielbranch closed 3 years ago

gabrielbranch commented 3 years ago

if I add a single item and attempt to call upload all the formData is empty when it goes to add the data to shareable in my console I am correctly adding form data params but they get wiped out somehow

If I add multiple items then it works.

What's do you think might be happening there?

gabrielbranch commented 3 years ago

My issue was my misunderstanding of how it works. It doesn't upload multiple files in a single request. It will send each file in a separate request.

So if you want to send form data you add it to the formData on the item and your api endpoint should be written to process singular files.

 _.each($scope.uploader.queue, function (item){
          item.formData.push({anId:someId}); // some unrelated data
          item.formData.push({fileName:item.file.name});
 });
$scope.uploader.uploadAll(result);