title: appending array to FormData and send via AJAX
body: <p>I'm using ajax to submit a multipart form with array, text fields and files.</p>
  
  <p>I append each VAR to the main data as so</p>
  
  <pre><code>var attachments = document.getElementById('files'); 
  var data= new FormData();
  
  for (i=0; i&lt; attachments.files.length; i++){
      data.append('file', attachments.files[i]);
      console.log(attachments.files[i]);
  
      data.append ('headline', headline);
      data.append ('article', article);
      data.append ('arr', arr);
      data.append ('tag', tag);
  </code></pre>
  
  <p>then I use the ajax function to send it to a PHP file to store inside sql DB.</p>
  
  <pre><code>$.ajax({    
      type: "post",
      url: 'php/submittionform.php',
      cache: false,
      processData: false,
      contentType: false,
      data: data,
      success: function(request) {$('#box').html(request); }
  })
  </code></pre>
  
  <p>But on the PHP side, the <code>arr</code> variable, which is an array appears as a string.</p>
  
  <p>When I don't send it with ajax as Form data but use the simple <code>$.POST</code> option I do get it as an array on the PHP side, but then I can't send the files as well.</p>
  
  <p>any solutions? </p>