0
            $scope.uploadFiles = function () {
             //debugger;
            var request = {
                method: 'POST',
                url: 'http://localhost/upload/',
                data: formdata,
                headers: {
                    'Content-Type': undefined
                }
            };

            // SEND THE FILES.
            $http(request)
                .success(function (d) {
                    alert(d);
                })
                .error(function () {
                });
        }

i am getting in console window like XMLHttpRequest cannot load http://localhost/upload/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:55555' is therefore not allowed access. The response had HTTP status code 405.

  • 1
    Possible duplicate of [AngularJS angular-file-upload cannot upload data to WebAPI 2 CORS](http://stackoverflow.com/questions/28142643/angularjs-angular-file-upload-cannot-upload-data-to-webapi-2-cors) – fracz Jun 02 '16 at 12:22

1 Answers1

0

If I understand this correctly, the app is running at http://localhost:55555 and you are trying to send a POST request to http://localhost/upload/ (which really means http://localhost:80/upload/). Your browser is not allowing you to do this since http://localhost:80/ and http://localhost:55555/ are different origins.

Perhaps you meant to say http://localhost:55555/upload/? This would solve your issue.

Otherwise you need to disable CORS in your browser or add the 'Access-Control-Allow-Origin: * header in your server at http://localhost:80/.

Community
  • 1
  • 1
Raphi
  • 174
  • 4
  • Thanks....i tried http://localhost:55555/upload/ also but getting same issue.i will try 'Access-Control-Allow-Origin: * otherwise i need write in services to upload images using C# or i should use some upload.php to move. – Desa Kumaaran Jun 07 '16 at 07:33