Exemplo n.º 1
0
 public function execute()
 {
     $model = new DocumentModel();
     $document = $model->getDocument();
     $filename = basename($document->name);
     $file_extension = strtolower(substr(strrchr($filename, "."), 1));
     switch ($file_extension) {
         case "gif":
             $ctype = "image/gif";
             break;
         case "png":
             $ctype = "image/png";
             break;
         case "jpeg":
         case "jpg":
             $ctype = "image/jpg";
             break;
         default:
     }
     header('Content-type: ' . $ctype);
     ob_clean();
     flush();
     readfile($document->path);
     exit;
 }
Exemplo n.º 2
0
 public function execute()
 {
     $model = new DocumentModel();
     $document = $model->getDocument();
     $filename = basename($document->name);
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . $filename);
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . filesize($document->path));
     readfile($document->path);
     exit;
 }
Exemplo n.º 3
0
 public static function downloadDocument()
 {
     $model = new DocumentModel();
     $document = $model->getDocument();
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . basename($document->name));
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . filesize($document->path));
     ob_clean();
     flush();
     readfile($document->path);
     exit;
 }