title: Cross-domain jQuery AJAX file upload
body: <p>So the point is I have a subdomain which is API endpoint for uploading files. But when I'm trying to upload anything with jQuery to this subdomain (from main www domain) I'm getting error</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://1.storage.site.net/upload" rel="noreferrer">http://1.storage.site.net/upload</a>. Origin <a href="http://www.site.net" rel="noreferrer">http://www.site.net</a> is not allowed by Access-Control-Allow-Origin.</p>
  </blockquote>
  
  <p>I tried everything: headers in nginx, headers in source code, I even tried sending file to stub file with just</p>
  
  <pre><code>&lt;?php
  
  header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
  header('Access-Control-Max-Age: 1000');
  header('Content-type: application/json');
  header('Access-Control-Allow-Headers: *');
  
  echo json_encode(['lulz' =&gt; 123]);
  </code></pre>
  
  <p>In two words: NOTHING WORKS.</p>
  
  <p>BUT. I noticed that small files (~1MB) upload correctly and files a little bit larger (say 5MB) — NOT (origin not allowed).</p>
  
  <p>Is there any way of solving that?</p>