title: How to use FormData for AJAX file upload?
body: <p>This is my HTML which I'm generating dynamically using drag and drop functionality.</p>
  <pre><code>&lt;form method=&quot;POST&quot; id=&quot;contact&quot; name=&quot;13&quot; class=&quot;form-horizontal wpc_contact&quot; novalidate=&quot;novalidate&quot; enctype=&quot;multipart/form-data&quot;&gt;
  &lt;fieldset&gt;
      &lt;div id=&quot;legend&quot; class=&quot;&quot;&gt;
          &lt;legend class=&quot;&quot;&gt;file demoe 1&lt;/legend&gt;
          &lt;div id=&quot;alert-message&quot; class=&quot;alert hidden&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class=&quot;control-group&quot;&gt;
          &lt;!-- Text input--&gt;
          &lt;label class=&quot;control-label&quot; for=&quot;input01&quot;&gt;Text input&lt;/label&gt;
          &lt;div class=&quot;controls&quot;&gt;
              &lt;input type=&quot;text&quot; placeholder=&quot;placeholder&quot; class=&quot;input-xlarge&quot; name=&quot;name&quot;&gt;
              &lt;p class=&quot;help-block&quot; style=&quot;display:none;&quot;&gt;text_input&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class=&quot;control-group&quot;&gt;  &lt;/div&gt;
          &lt;label class=&quot;control-label&quot;&gt;File Button&lt;/label&gt;
  
          &lt;!-- File Upload --&gt; 
          &lt;div class=&quot;controls&quot;&gt;
              &lt;input class=&quot;input-file&quot; id=&quot;fileInput&quot; type=&quot;file&quot; name=&quot;file&quot;&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;control-group&quot;&gt;    
  
          &lt;!-- Button --&gt; 
          &lt;div class=&quot;controls&quot;&gt;
              &lt;button class=&quot;btn btn-success&quot;&gt;Button&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/fieldset&gt;
  &lt;/form&gt; 
  </code></pre>
  <p>This is my JavaScript code:</p>
  <pre><code>&lt;script&gt;
      $('.wpc_contact').submit(function(event){
          var formname = $('.wpc_contact').attr('name');
          var form = $('.wpc_contact').serialize();               
          var FormData = new FormData($(form)[1]);
  
          $.ajax({
              url : '&lt;?php echo plugins_url(); ?&gt;'+'/wpc-contact-form/resources/js/tinymce.php',
              data : {form:form,formname:formname,ipadd:ipadd,FormData:FormData},
              type : 'POST',
              processData: false,
              contentType: false,
              success : function(data){
              alert(data); 
              }
          });
     }
  </code></pre>