title: Using php to force download a pdf
body: <p>Im trying to get a website to have a button that forces a download of a pdf.</p>
  
  <p>Heres the html of the button:</p>
  
  <pre><code>    &lt;a href=scripts/download.php&gt;
      &lt;input type="image" src="images/download.gif" alt="Submit button"/&gt;
      &lt;/a&gt;
  </code></pre>
  
  <p>And the php script so far:</p>
  
  <pre><code>    &lt;?php
      header('Content-Type: application/pdf');
      header('Content-disposition: attachment;filename=documents/ECM_IT_ResumeDownload.pdf');
      readfile('documents/ECM_IT_ResumeDownload.pdf');
      ?&gt;
  </code></pre>
  
  <p>This seems to download the file fine but when I go to open it i get this error:</p>
  
  <p>"Adobe Reader could not open 'documents_ECM_IT_ResumeDownload.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><strong>EDIT</strong>
  Opened the pdf in a text editor and got this message:</p>
  
  <p>"<br />
  <b>Warning</b>:  readfile(documents/ECM_IT_ResumeDownload.pdf) [function.readfile]: failed to open stream: No such file or directory in <b>html/scripts/download.php</b> on line <b>4</b><br />
  "</p>
  
  <p>The document is definitely there though. in html/documents/ECM_IT_ResumeDownload.pdf</p>