title: Handle when $_FILES is empty but $_POST has file data
body: <p>I've looked at several answers here and they all use jQuery's <code>.ajax()</code> method. Below I have a vanilla JS method that is a trimmed down version which I am using with some success.</p>
  
  <pre><code>       function ajax(options){
              var settings = {
                  method : 'POST',
                  url : 'endpoint.php',
                  data : null,
                  done : function(){},
                  fail : function(){},
                  complete : function(){}
              };
  
              if(options) for(option in options) settings[option] = options[option];
  
              var xhttp = new XMLHttpRequest();
              xhttp.onreadystatechange = function(){
                  if (xhttp.readyState == 4){
                      if(xhttp.status == 200){
                          settings.done(xhttp.responseText);
                      } else {
                          settings.fail(xhttp.responseText);
                      };
                      settings.complete(xhttp.responseText);
                  };
              };
              xhttp.open(settings.method, settings.url, true);
              xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
              xhttp.send(settings.data);
          };
  </code></pre>
  
  <p>Next is the function that assigns the file to a new <code>FormData()</code> object.</p>
  
  <pre><code>        function beginUpload(index){
              var file = files.files[index];
              var pkg = new FormData();
              pkg.append('file', file);
              pkg.append('size', file.size);
              ajax({
                  data : pkg,
                  done : function(res){
                      console.log(res);
                  }
              });
          };
  </code></pre>
  
  <p>Now, here's the problem: All tutorials and examples I've found say that the file will be found in the <code>$_FILES</code> global variable after the request is completed. I get a 200 response doing a <code>var_dump()</code> and <code>$_FILES</code> for me is empty but <code>$_POST</code> is not. <code>$_POST</code> has what looks like the file inside of it. Checked all the php.ini settings <a href="https://stackoverflow.com/questions/3586919/why-would-files-be-empty-when-uploading-files-to-php">from this question</a>.</p>