I am trying to post file on my server as soon as it will get attached with directve so I did api call but I got this error while doing. I don't know where am i going wrong
here is my code
app.directive('fileModel',fileupload);
fileupload.$inject = ['$http','$parse'];
function fileupload ($http,$parse) {
return {
restrict: 'A',
link: function(scope, element, attrs,$http) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function(){
scope.$apply(function($http){
modelSetter(scope, element[0].files[0]);
var fd = new FormData();
fd.append('file', element[0].files[0]);
fd.append('id', user_id);
var uploadUrl = "https://******/routes/contactRoute.php?action=upload";
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}).
then(function successCallback(response) {
console.log(response)
}, function errorCallback(response) {
console.log(response)
});
});
});
}
};
}