title: Uploading a pdf file generated by jsPDF to php server
body: <p>I am uploading a pdf file generated by jsPDF to the php server. What I am missing here? How can I check the pdf file content before sending it? </p>
  
  <p>In JS, </p>
  
  <pre><code>var doc = new jsPDF(parameters);
      doc.addHTML($('#test')[0], 0, 0, {
  }, function() {
      pdf = doc.output('blob');
  });
  
   $.ajax({
              url: 'upload.php',
              type: 'post',
              data: {data: pdf},
              processData: false,
   }).done(function (data) { 
         alert(data);
   }).fail(function (xhr, status, err) { 
         alert(err);
   });
  </code></pre>
  
  <p>And in php, </p>
  
  <pre><code>&lt;?php
  if(!empty($_POST['data'])){
      $data = base64_decode($_POST['data']);
      file_put_contents( "tmp/test.pdf", $data);
   else {
       echo "error";
   }
  ?&gt;
  </code></pre>