Using PHP force download for all files
<p>My question is, is there a way to use the header download PHP method for all files type;</p>

<pre><code>    &lt;?php

$fileid = $_GET['fid'];
$filename = $_GET['fn'];
 $auth_code = $_GET['dlauth'];
$folder = $_GET['fi'];
echo $file = $folder."/".$filename;

if (empty($fileid) || empty($filename) || empty($auth_code) || empty($folder)) {

    echo "Malformed ID, please go back and try to download again";

    } else {

        if (strlen($auth_code) &gt; 25) {

            echo "Download session has expired or is malforned";

            }  else {






  header("Content-Disposition: attachment; filename=$filename");

  header('Content-Length: ' . filesize($file));
  header("Pragma: no-cache");
  header("Expires: 0");

  readfile($file);





                }



        }

?&gt;
</code></pre>

<p>Because this downloads zipped files etc, perfectly fine. However when it comes to anything else, it just corrupts.</p>

<p>Anyone got any clues without using switch statements to detirmine the content type with file extensions.</p>

<p>Thanks!</p>
