0

I'm trying to execute the following code, but it gives me this error:

enter image description here

$http.post('/api/updatePhoto/'+$scope.item.id)

$scope.onFileSelect = function($files) {

     for (var i = 0; i < $files.length; i++) {

         var file = $files[i];

         $scope.upload = $upload.upload({

         $http.post('/api/updatePhoto/'+$scope.item.id) 

          data: {myObj: $scope.myModelObj},
          file: file,
      })

    }).success(function(data){
   alert(data);

  })
 }

What's wrong with the code?

1
  • Please always be sure to read the descriptions that appear when selecting tags! Commented Mar 23, 2014 at 3:25

1 Answer 1

2

The $upload object you specified needs an object to work, you're declaring an invalid object at:

 $upload.upload({
      $http.post('/api/updatePhoto/'+$scope.item.id) 
      data: {myObj: $scope.myModelObj},
      file: file,
  });

The $upload object needs a url property, like this:

$upload.upload({
    url: '/api/updatePhoto/' + $scope.item.id,
    data: {myObj: $scope.myModelObj},
    file: file,
});

This way you're passing an actual javascript object to the upload function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.