title: Send array of files using AJAX
body: <p>Say I have an array which contains a few images:</p>
  <pre><code>var images = [image1, image2, image3]
  </code></pre>
  <p>How do I send these images to a php file using AJAX in a single request?</p>
  <p>The following code did not work:</p>
  <pre><code>$.ajax({
      url: 'PHP/posts.php',
      type: 'post',
      data: {data: images},
      success: function(data) {
        alert(data);
        location.reload();
      }
    });
  </code></pre>
  <p>My HTML:</p>
  <pre><code>&lt;div id=&quot;newPostFile&quot;&gt;
      &lt;label for=&quot;newPostFiles&quot;&gt;&lt;i class=&quot;fa fa-file-text-o&quot; id=&quot;newPostFileIcon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;&lt;/label&gt;
      &lt;input type=&quot;file&quot; name=&quot;newPostFiles&quot; id=&quot;newPostFiles&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>Endgoal:</strong>
  Whenever a file is selected, the file is added to the array and when the submit button is clicked, all the files are uploaded at once.</p>