Rectangle 27 0

javascript How to send a file on cross domain with XMLHttpRequest?

If you are using XHR2 to upload files cross-origin, AND you want to track upload progress, your server will need to handle preflight (OPTIONS) requests, which the browser will send before it sends the underlying upload POST request. This is, of course, in addition to the support this server must have for non-preflighted CORS requests.

If you have no control over the server and it does not handle OPTIONS/preflight requests, you will not be able to make use of upload progress events.

XHR2's upload progress specifically triggers a preflight, even if nothing else about the upload POST request requires the cross-origin request to be preflighted. I stumbled into this a while back myself.