jquery - Uploading files Formdata and JSON data in the same request with Angular JS -


how combine 2 $http.post single http post?

$scope.mymethod = function(){     var fd = new formdata();     angular.foreach($scope.files, function(file){         fd.append('file', file);     });      $http.post('my_url', fd, {         transformrequest: angular.identity,         headers: {'content-type': undefined}     }).success(function(result){         console.log(result);     });      $http.post('my_url', {imgx: $scope.imgx, imgy: $scope.imgy, imgh: $scope.imgh, imgw: $scope.imgw}).success(         function(data){         console.log(data);     }); } 

any appreciated, thank you

try this:  $scope.mymethod = function(){     var fd = new formdata();     angular.foreach($scope.files, function(file){         fd.append('file', file);     });  var data = {};     data.fd = fd;     data.otherdata  =   {imgx: $scope.imgx, imgy: $scope.imgy, imgh: $scope.imgh, imgw: $scope.imgw};        $http.post('my_url', fd, {         transformrequest: angular.identity,         headers: {'content-type': undefined}     }).success(function(result){         console.log(result);     });   } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -