title: Save base64 encoded pdf on server with php
body: <p>I have a call to a web service that gives me a response back in the format of a base64 encoded pdf file. I need to save the pdf to a folder on the server. </p>
  
  <p>I can't get the document saved in the folder. It always saves the file locally on the computer and not to the server.</p>
  
  <p>Here is the code i have at this moment.</p>
  
  <pre><code>header('Content-type: application/pdf');
  header('Content-Disposition: attachment; filename="doc-'.$document.'.pdf"');
  file_put_contents('~/pdf/'.$document.'.pdf', $wc-&gt;out-&gt;document);
  </code></pre>
  
  <p>Does someone have a suggestion where i can find the solution?</p>
  
  <p>thx</p>