title: jquery file upload queue with formdata
body: <p>I am trying to upload files one by one using this script i made but instead it uploads them all at once.</p>
  
  <p>files_obj store the files inputted through the html input element.</p>
  
  <pre><code>var files_obj = {};
  
  var uploading = false;
  
  function upload_all()
  {               
      $.each(files_obj, function(i, file) {
  
          if( !uploading )
          {
              uploading = true;
  
              var xhr = new XMLHttpRequest;
              var formdata = new FormData();
  
              fd.append("file",file);
  
              xhr.open('POST','upload.php',true);
              xhr.send(formdata);
              uploading = false;
  
          }
      });
  }
  </code></pre>
  
  <p>the variable "uploading" stores the current status of the file being uploaded, so when it has been uploaded it is set to false and the next file in the queue should upload.</p>