title: How to send a string along with file via ajax request to a php file?
body: <p>I got a php file that saves file to server to a folder called upload it receives file via an ajax request every thing works fine so far the next requirement is to send a string along with the file to specify an upload folder &amp; sub folder like "Course/Math" how to achieve that?</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$( document ).ready(function() {
  $('#Upload').click(function(){
      var formData = new FormData($('form')[0]);
      $.ajax({
          url: 'uploadFile.php',  
          type: 'POST',
          xhr: function() {  
              var myXhr = $.ajaxSettings.xhr();
              if(myXhr.upload){ 
                  myXhr.upload.addEventListener('progress',progressHandling, false);
              }
              return myXhr;
          },
          success: completeHandler,
          data: formData,
          cache: false,
          contentType: false,
          processData: false
      });
  });
  
  var progressHandling = function(e){
      if(e.lengthComputable){
          var percent = Math.round((e.loaded / e.total) * 100);
          $('#uploadprogress').css('width', percent+'%');
      }
  }
  
  var completeHandler = function(data){
      $('#message').text(data);
      $('#uploadprogress').css('width', '0%');
      $('#file').val('');
  };
  });     
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  if ($_FILES["file"]["error"] &gt; 0) {
  
  } else {
    move_uploaded_file($_FILES["file"]["tmp_name"],
        "upload/" . $_FILES["file"]["name"]);
    echo true;
  }
  ?&gt;
  </code></pre>