SendFile.php

浏览该文件的文档。
00001 <?php
00003 // FleaPHP Framework
00004 //
00005 // Copyright (c) 2005 - 2008 QeeYuan China Inc. (http://www.qeeyuan.com)
00006 //
00007 // 许可协议,请查看源代码中附带的 LICENSE.txt 文件,
00008 // 或者访问 http://www.fleaphp.org/ 获得详细信息。
00010 
00020 // {{{ constants
00021 define('SENDFILE_ATTACHMENT', 'attachment');
00022 define('SENDFILE_INLINE', 'inline');
00023 // }}}
00024 
00035 class FLEA_Helper_SendFile
00036 {
00044     function sendFile($serverPath, $filename, $mimeType = 'application/octet-stream')
00045     {
00046         header("Content-Type: {$mimeType}");
00047         $filename = '"' . htmlspecialchars($filename) . '"';
00048         $filesize = filesize($serverPath);
00049         $charset = FLEA::getAppInf('responseCharset');
00050         header("Content-Disposition: attachment; filename={$filename}; charset={$charset}");
00051         header('Pragma: cache');
00052         header('Cache-Control: public, must-revalidate, max-age=0');
00053         header("Content-Length: {$filesize}");
00054         readfile($serverPath);
00055         exit;
00056     }
00057 }

Generated at Sat Feb 2 15:18:51 2008 for FleaPHP by  doxygen 1.5.3