Download javascript and HttpHandler syntax file: no file and always "OPTIONS" HttpMethod

I am struggling to download the Blueimp jQuery downloader that runs on MVC 3 with IIS 7.5 on Windows Server 2008 R2. I use HttpHandler to handle the loading that is called. But the HttpHandler never receives the file, and the HttpMethod β€œPOST” or β€œPUT” is always β€œOPTIONS”. Does anyone know what's wrong here?

The only message I receive when I refuse a callback from the bootloader is an β€œerror”.

Here is my JS:

$('#fileupload').fileupload( { acceptFileTypes: /(\.|\/)(pdf)$/i, fail: function (e, data) { alert("Error: " + data.errorThrown + " Text-Status: " + data.textStatus); // data.jqXHR; }, maxNumberOfFiles: 1 /*add: function (e, data) { data.formData = [{ name: "name1", value: "1" }, { name: "name2", value: "2"}]; data.submit(); }, submit: function (e, data) { //data.formData = [{ name: "name1", value: "1" }, { name: "name2", value: "2"}]; }*/ } ); 

Thanks so much for any help!

+6
source share
2 answers

Ok, adding some code did the trick:

server side:

  HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "http://example.net"); HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true"); 

on the client side:

 $('#fileupload').fileupload( { xhrFields: { withCredentials: true } } 
+4
source

When your page is submitted from domain1.com and you are trying to upload it to domain2.com. your request for sending over HTTP is preprogrammed.

your domain2.com should actually allow domain1.com to download the file. different servers have different mechanisms for this.

Just read about how to install "Access-Control-Allow-Origin" for your server, which in this case is IIS.

for Amazon S3, quite simply they have the political xml that you need to update for this.

0
source

Source: https://habr.com/ru/post/908841/


All Articles