title: Jquery/Ajax Form Submission (enctype="multipart/form-data" ). Why does 'contentType:False' cause undefined index in PHP?
body: <p>I have been trying to submit a form with enctype="multipart/form-data". I have this setting because the form will involve jpeg/png uploads once I have figured out the ajax submission for text inputs.</p>
  
  <ol>
  <li><p>the php works fine when referencing the script using action within the form html.</p></li>
  <li><p>the form data seems to be retrieved correctly by the below jquery because the alert line shows: productName=Test+Name&amp;productDescription=Test+Description&amp;OtherProductDetails=</p></li>
  <li><p>the returned data printed to my HTML by the jquery success function is a php error saying:Undefined index: productName</p></li>
  <li><p>removing contentType:false fixes the problem.</p></li>
  </ol>
  
  <p>When i google jquery/ajax multipart/form-data submission, the top hits at least mainly include 'contentType:false'. Please could someone explain the reason to me? </p>
  
  <p><a href="http://digipiph.com/blog/submitting-multipartform-data-using-jquery-and-ajax" rel="noreferrer">http://digipiph.com/blog/submitting-multipartform-data-using-jquery-and-ajax</a>
  <a href="http://hayageek.com/jquery-ajax-form-submit/" rel="noreferrer">http://hayageek.com/jquery-ajax-form-submit/</a>
  <a href="https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax">Sending multipart/formdata with jQuery.ajax</a></p>
  
  <p>The jquery API documentation says:
  contentType (default: 'application/x-www-form-urlencoded; charset=UTF-8')
  Type: String
  When sending data to the server, use this content type.</p>
  
  <p>Why would we need to set it to false for a multipart/form-data submission?
  When would the false setting be needed at all?</p>
  
  <p>Jquery:</p>
  
  <pre><code>  $("#addProductForm").submit(function (event) {
        event.preventDefault();
        //grab all form data  
        var formData = $(this).serialize();
  
        $.ajax({
            url: 'addProduct.php',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (returndata) {
                $("#productFormOutput").html(returndata);
                alert(formData);
            },
            error: function () {
                alert("error in ajax form submission");
            }
        });
  
        return false;
    });
  </code></pre>