生产厂家,日韩国产一区二区三区四区五区,已满十八带好纸巾从此转人 http://www.aucma-it.com/blog 中山php|最優網絡 Mon, 13 May 2013 04:56:43 +0000 en hourly 1 http://wordpress.org/?v=3.1.4 php強制下載文件,避免文件或者圖片直接在瀏覽器打開 http://www.aucma-it.com/blog/view-194.html http://www.aucma-it.com/blog/view-194.html#comments Thu, 25 Aug 2011 07:08:29 +0000 lin http://www.aucma-it.com/blog/?p=194 以下代碼是FLEAPHP框架自帶的文件下載助手類

/**
* FLEA_Helper_SendFile 類用于向瀏覽器發送文件
*
* 利用 FLEA_Helper_SendFile,應用程序可以將重要的文件保存在
* 瀏覽器無法訪問的位置。然后通過程序將文件內容發送給瀏覽器。
*
* @package Core
* @author 起源科技 (www.qeeyuan.com)
* @version 1.0
*/
class FLEA_Helper_SendFile
{
/**
* 向瀏覽器發送文件內容
*
* @param string $serverPath 文件在服務器上的路徑(絕對或者相對路徑)
* @param string $filename 發送給瀏覽器的文件名(盡可能不要使用中文)
* @param string $mimeType 指示文件類型
*/
function sendFile($serverPath, $filename, $mimeType = 'application/octet-stream')
{
header("Content-Type: {$mimeType}");
$filename = '"' . htmlspecialchars($filename) . '"';
$filesize = filesize($serverPath);
$charset = FLEA::getAppInf('responseCharset');//根據實際文件編碼類型,如utf-8,gbk
header("Content-Disposition: attachment; filename={$filename}; charset={$charset}");
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header("Content-Length: {$filesize}");
readfile($serverPath);
exit;
}
}

]]>
http://www.aucma-it.com/blog/view-194.html/feed 10
主站蜘蛛池模板: 会同县| 沙洋县| 宜州市| 霞浦县| 仪陇县| 丹棱县| 林周县| 建宁县| 陵水| 桦南县| 获嘉县| 五指山市| 静宁县| 黄骅市| 黄浦区| 岚皋县| 楚雄市| 红原县| 南岸区| 中方县| 七台河市| 抚远县| 海晏县| 洛扎县| 凯里市| 米易县| 淄博市| 义乌市| 两当县| 炉霍县| 南京市| 房山区| 巴青县| 五大连池市| 海林市| 尼勒克县| 临洮县| 青田县| 无极县| 铜鼓县| 静乐县|