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 & sub folder like "Course/Math" how to achieve that?
JS
$( 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('');
};
});     
PHP
<?php
if ($_FILES["file"]["error"] > 0) {
} else {
  move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
  echo true;
}
?>
 
     
     
    