After try upload images get in console error *405 (Method Not Allowed) *any solution?
My source: <!DOCTYPE html> <html> <head> <title>AngularJS File Upoad Example with $http and FormData</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script> </head> <body ng-app="fupApp"> <div ng-controller="fupController"> <input type="file" id="file1" name="file" multiple ng-files="getTheFiles($files)" /> <input type="button" ng-click="uploadFiles()" value="Upload" /> </div> <script> angular.module('fupApp', []) .directive('ngFiles', ['$parse', function ($parse) { function fn_link(scope, element, attrs) { var onChange = $parse(attrs.ngFiles); element.on('change', function (event) { onChange(scope, { $files: event.target.files }); }); }; return { link: fn_link } } ]) .controller('fupController', function ($scope, $http) { var formdata = new FormData(); $scope.getTheFiles = function ($files) { angular.forEach($files, function (value, key) { formdata.append(key, value); }); }; // NOW UPLOAD THE FILES. $scope.uploadFiles = function () { var request = { method: 'POST', url: '/img/', data: formdata, headers: { 'Content-Type': 'application/json', /*or whatever type is relevant */ 'Accept': 'application/json' /* ditto */ } }; // SEND THE FILES. $http(request) .success(function (d) { alert(d); }) .error(function () { alert("error neki"); }); } }); </script> </body> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
