Thursday, 5 January 2012

downloads function in cake php

function admin_downloadForms($filename=null) {
        //echo $filename=base64_decode($filename);
      
     $filename = WWW_ROOT . "uploads/uploadform/".$filename;
                if (file_exists($filename)) {
                header("Pragma: public");
                header("Expires: 0");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Cache-Control: private", false);
                header("Content-Type: application/force-download");
                header("Content-Type: application/pdf");
                header("Content-Description: File Transfer");
                header("Content-Disposition: attachment; filename=" . basename($filename) . ";");
                header("Content-Transfer-Encoding: binary");
                header("Content-Length: " . filesize($filename));
                readfile($filename) or die('Errors');
                exit(0);
                }
                $this->autoRender=false;
    }

No comments:

Post a Comment