title: AJAX upload file and text not work
body: <p>I am using this ajax code for submit form and upload multiple input file. I want to send all form data via ajax. The text input successfully send but file input was not successful post via ajax!
  How to change this code? </p>
  
  <pre><code>$("#add_order").click(function () {
  
      //*****get data input
      var formData = new FormData(); 
          formData.append( 'action', 'add_order');
          formData.append( 'customer_name', $('input[name=customer_name]').val());
          formData.append( 'date', $('input[name=date]').val());
          formData.append( 'order_status', $('input:radio[name=order_stautus]').val());
          formData.append( 'total_price', $('input[name=totalprice]').val());
          formData.append( 'quits', $('input[name=quits]').val());
          formData.append( 'debt', $('input[name=debt]').val());
          formData.append( 'desc', $('#desc').val());
          formData.append( 'desc2', $('#desc2').val());
  
      $.each($("input[type=file]"), function(i, obj) {
          $.each(obj.files,function(j,file){
              formData.append('photo['+i+']', file);
          });
      });
      $.ajax({
          url: "includes/ajax/ajax.php",
          data: formData,
          processData: false,
          contentType: 'multipart/form-data',
          type: 'POST',
          dataType:'json',
          success: function(response){
             //load json data from server and output message     
             if(response.type == 'error'){ //load json data from server and output message     
                 output = '&lt;div class="alert alert-danger"&gt;'+response.text+'&lt;/div&gt;';
             }else{
                 output = '&lt;div class="alert alert-danger"&gt;'+response.text+'&lt;/div&gt;';
             }
             $("#results").append(output).slideDown();
          } 
      });        
  });
  </code></pre>
  
  <p>PHP code for get form data:</p>
  
  <pre><code>if($_POST['action']=='add_order'){
  
      $customer_id = 1;
      $date = $_POST['date'];
      $status = $_POST['order_status'];
      $total_price = $_POST['total_price'];
      $quits = $_POST['quits'];
      $debt = $_POST['debt'];
      $desc = $_POST['desc'];
      $desc2 = $_POST['desc2'];
  
      for($i=0; $i&lt;count($_FILES['photo']['name']); $i++) {
          //Get the temp file path
          $tmpFilePath = $_FILES['photo']['tmp_name'][$i];
  
          //Make sure we have a filepath
          if ($tmpFilePath != ""){
            //Setup our new file path
            $newFilePath = "../../uploads/orders/" . $_FILES['photo']['name'][$i];
  
            //Upload the file into the temp dir
            if(move_uploaded_file($tmpFilePath, $newFilePath)) {
  
              //Handle other code here
  
            }
          }
        }
  </code></pre>
  
  <p>formData console.log:
  <img src="https://i.stack.imgur.com/RZ4HR.jpg" alt="enter image description here"></p>