コード例 #1
0
ファイル: File.php プロジェクト: kvenkat971/FileZ
 /**
  * Send a file through the standart output
  * @param App_Model_File $file      File to send
  */
 protected function sendFile(App_Model_File $file, $forceDownload = true)
 {
     $mime = $file->getMimetype();
     header('Content-Type: ' . $mime);
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . $file->file_size);
     if ($forceDownload) {
         header('Content-Disposition: attachment; filename="' . iconv("UTF-8", "ISO-8859-1", $file->getFileName()) . '"');
     }
     return file_read($file->getOnDiskLocation());
 }