title: How to get data from FormData in a php file
body: <p>I have the following form:</p>
  
  <pre><code>&lt;form id="f-comment" class="form" method="post" action="submit_img_comment.php"&gt;
      &lt;textarea name="comment"&gt;&lt;/textarea&gt;
      &lt;input type="submit" value="Publish" data-params='{"imageid":&lt;?php echo $imageid; ?&gt;}'&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the following javascript:</p>
  
  <pre><code>$(document).on("submit", ".form", function(e) {
      e.preventDefault();
  
      // what form are you submitting?
      var form = $("#" + e.target.id);
  
      var data = new FormData(this);
      var params = $("input[type=submit]", this).data("params"); // parameters to send along with data
      data.append("params", params);
  
      // data is ok
      console.log(params)
  
      $.ajax({
          type: form.attr("method"),
          url: "include/" + form.attr("action"),
          data: data,
          dataType: "json",
          contentType: false,
          processData: false,
          cache: false
      }).done(function(data) {
          alert(data['msg']);
      }).fail(function(data) {
          alert("Error: Ajax Failed.");
      }).always(function(data) {
          // always do the following, no matter if it fails or not
      })
  });
  </code></pre>
  
  <p>in my php file (submit_img_comment.php) im able to get the comment, like this</p>
  
  <pre><code>$_POST['comment'];
  </code></pre>
  
  <p>But, when i try to get the imageid, like this</p>
  
  <pre><code>$_POST['imageid'];
  </code></pre>
  
  <p>I get the error: <strong>Undefined index: imageid</strong></p>
  
  <p>The comment is part of the form, but the imageid is send as a parameter and appended in FormData.</p>
  
  <p>How do i get the imageid in my php file?</p>