 <p>A clean example.</p> <pre><code>&lt;?php header('Content-Type: application/download'); header('Content-Disposition: attachment; filename="example.txt"'); header("Content-Length: " . filesize("example.txt")); $fp = fopen("example.txt", "r"); fpassthru($fp); fclose($fp); ?&gt; </code></pre>