0

I am trying to bind file input type data to the angular.js controller but after submit the data is undefined.

<input type="file" name="image" class="form-control upload " ng-model="image" value="upload">
             <input type="submit" ng-click="uploadimage()" value="upload" class="btn btn-default">

angular js controller is

//upload image
$scope.uploadimage = function() {
    console.log($scope.image);
}
4
  • 1
    console.log($scope.image); Commented Aug 11, 2017 at 12:14
  • i tried $scope.image too but not working Commented Aug 11, 2017 at 12:15
  • please provide more code, at least html and angular module with definition and controllers Commented Aug 11, 2017 at 12:19
  • ng-model won't work with input type file, you have to write a custom directive for that stackoverflow.com/questions/45628050/… . Or you can use any plugin for this. Commented Aug 11, 2017 at 14:13

1 Answer 1

1

The file input type is missing from the ng-model directive, so you need to install a package for file uploads with AngularJS.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.