nervgh / angular-file-upload

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

formData is not being uploaded. #292

Open pranavkumar opened 10 years ago

pranavkumar commented 10 years ago

what is the correct way of sending formData with individual file?

rboughani commented 10 years ago
 var uploader = $scope.uploader = new FileUploader({
     url: './api/mockups',
     method: 'POST',
     queue: [],
     formData : [{x: $scope.x, b: $scope.b}]
 });

  uploader.onBeforeUploadItem = function(item) {

    //if you want to change dynamically your url with item.url = ...
     item.formData = [{x: $scope.x, b: $scope.b}];       
     console.log(item.formData);
 };
johnwesthoff commented 9 years ago

use this instead:

item.formData.push({x: $scope.x});

Sabonzy commented 9 years ago

@johnwesthoff where should item.formData.push({x: $scope.x}); be added should it be in the onBefore callback

sashaaKr commented 9 years ago

@Sabonzy use onBeforeUploadItem callback:

imageUploader.onBeforeUploadItem = function (item) { item.formData = [{ value:'value' }]; }