title: Jquery,Ajax post file upload
body: <p>I need to post the file upload to the current page by jquery, then upload the file
  , and then insert file upload, but the code not work... jquery can't post the file upload to the form:</p>
  
  <pre><code> &lt;form class="form-inline" role="form" id="form" enctype="multipart/form-data"&gt;
   &lt;td colspan="3"&gt;&lt;input type="file" name="pic_map" id="pic_map"&gt;&lt;/td&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>and this is javascript:</p>
  
  <pre><code> $('#save').click(function (e) {
      $.post(
              "index.php?page=form1_sub1&amp;pguid=&lt;?php echo $pguid;?&gt;",
              $("#form").serialize()
          )
          .done(function (data) {
              console.log(data);
              window.open('index.php?page=form1_sub2&amp;pguid=&lt;?php echo $pguid;?&gt;', '_self');
          })
          .fail(function () {
              alert('&lt;?php echo _CONNECTION_ERROR; ?&gt;');
          });
  });
  </code></pre>
  
  <p>and this is php code:</p>
  
  <pre><code> $files = $_FILES['pic_map']['name'];
  if(!$db-&gt;upload($_FILES['pic_map'], 'uploads/maps/'.$files)) {
      exit('file error');
  }
  </code></pre>