Cannot open PDF file downloaded using php
<p>I am using the following php code to make pdf file download. I am able to download the pdf file but cannot open it. What I am doing wrong? Can anyone help me?<br><br>
download.php</p>

<pre><code>&lt;?php
$file = 'Rev.pdf';
$filepath = "doc/" . $file;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream; charset=utf-8');
header('Content-Disposition: attachment; filename='.basename($filepath));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filepath));
ob_clean();
flush();
readfile($filepath);
exit;
?&gt;
</code></pre>

<p>Updated:<br>
When I try to open it after download on browser, I get following error.
<a href="https://i.stack.imgur.com/dzLnm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dzLnm.png" alt="enter image description here"></a></p>

<p>Update2:<br>
Following is my HTML</p>

<pre><code>&lt;a href="download.php"&gt;download&lt;/a&gt;
</code></pre>

<p>Update3: SOLVED<br>
First of all I want to say sorry to make you all trouble. I have solved the  issue. Actually my PDF file itself was corrupted. So I created new pdf file and it's working well. Once again thank you all for hearing my problem and giving suggestions.</p>