title: How to pass selected file to php script using jQuery?
body: <p>The following form is what I use:</p>
  
  <pre><code>&lt;form id="form-attachment" action="" method="post" enctype="multipart/form-data"&gt;
      &lt;input name="attachment" type="file" /&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is what I do with jQuery:</p>
  
  <pre><code>$('body').on('submit', '#form-attachment', function(e) {
  
      e.preventDefault();
      var data = $(this).serialize();
  
      console.log('fine', data);
  
      var url = 'imageupload.php';
  
      $.ajax({
          type : "POST",
          url : url,
          data : data,
  
          success : function(response) {
              console.log('success: ' + response);
          },
          complete : function(response) {
              console.log('complete: ', response);
          },
          error: function(response) { 
              console.log('error: ', response); 
          }
      });
  });
  </code></pre>
  
  <p>And this is my <strong>imageupload.php</strong> file:</p>
  
  <pre><code>$response = array();
  $response["c"] = isset($_FILES["attachment"]);
  
  echo json_encode($response);
  </code></pre>
  
  <p>And this is result on console on <code>submit()</code>:</p>
  
  <blockquote>
    <p>success: {"c":false}</p>
  </blockquote>
  
  <p>So, what is wrong? Why my file is not visible at all?</p>