Jimmy Mac

Jimmy Mac

  • 0
  • 4
  • 9.1k

"Cross-Origin Request Blocked" when using jquery file upload

Dec 22 2014 3:52 AM
Hi,

although i assigned for controller as

[EnableCors(origins: "*", headers: "*", methods: "*")]
or
[EnableCors(origins: "*", headers: "x-requested-with, Content-Type, origin, authorization, accept, client-security-token", methods: "*", SupportsCredentials = true)]
or
[EnableCors(origins: "http://localhost:54189", headers: "x-requested-with, Content-Type,
origin, authorization, accept, client-security-token", methods: "*")]

for client side, i created a ajax request as below, it doesn't work. The browser occur "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:54189/portfolio/upload/. This can be fixed by moving the resource to the same domain or enabling CORS."

$('#fileupload').fileupload({
      url: "http://localhost:54189/portfolio/upload/",
      multiple: true,
      type: "Post",
      contentType: 'application/json; charset=utf-8',
      crossDomain: true,
      headers: { 'Access-Control-Allow-Origin': '*' },
      add: function (e, data) {

               data.submit();
      }
})
What is the error ? Please, share with me if you know something. Thanks.