Downloading empty file
<p>For the life of me I can't see why, but it has the correct file name and all, but the files themselves are empty after download. As far as I can see its going to the correct spot, the database has the correct info too. </p>

<pre><code>function download()
{
    global $session,$project,$config,$args;

    $fid = $args[0];
    $query = query('SELECT * FROM files WHERE id = ?',$fid);
    if(num($query) == 1)
    {
        $file = fetch($query);
                    //$happyfix = "http://imengine.gofreeserve.com/admin";
        $filename = URL . "/_files/{$file-&gt;in_project}/{$file-&gt;in_folder}/" . md5($fid) . ".{$file-&gt;extension}";
        //$filename = $happyfix . "/_files/{$file-&gt;in_project}/{$file-&gt;in_folder}/" . md5($fid) . ".{$file-&gt;extension}";
                    if(ini_get('zlib.output_compression'))
        {
            ini_set('zlib.output_compression', 'Off');

        }
        header("Pragma: public"); // required
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private",false); // required for certain browsers 
        header("Content-Type: $file-&gt;mimetype");
        // change, added quotes to allow spaces in filenames, by Rajkumar Singh
        header("Content-Disposition: attachment; filename=\"".$file-&gt;name . '.' . $file-&gt;extension."\";" );
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: ".filesize($filename));
        readfile("$filename");
        exit();
    }
    else
    {
        redirect('That file does not exist','','error');
    }
}
</code></pre>
