php如何实现文件下载 如题~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function fileDown($strFilePath, $strFileName, $strMimeType) { //check to exist the file if(file_exists($strFilePath) == false) return false; $fpFile = fopen($strFilePath, "r"); if($fpFile == false) return false; if($strFileName != null) { $nFileSize = filesize($strFilePath); if(is_null($strMimeType) == true || $strMimeType == "") $strMimeType = "application/octet-stream"; if(is_null($strMimeType) == true || $strMimeType == "") $strMimeType = "application/unknown"; Header("Content-Type: ". $strMimeType .";"); Header("Content-Disposition: attachment; filename=\"$strFileName\""); Header("Content-Length: $nFileSize"); Header('Accept-Ranges: bytes'); Header("Cache-control: private"); Header('Pragma: private'); Header("Expires: 0"); } fpassthru($fpFile); return true; }} 路径直接指向文件名或者header()echo file_get_contents() copy 即可 --------------完美的签名线-----------------网页游戏开发第一站 http://dev.web863.com 出错:php执行时间超了 请教,千万条记录怎么快速查询出来. 生成摘要的问题 js里面的对象ajax post到php端直接变成数组了? 急:如何用php的curl取这个页面的内容? 拜求各位大人:php换个硬盘后不能用问题 请问:列出子目录的一个怪问题 请问类似京东筛选前台已选择是通过什么方法实现的? list函数为啥这样写,获取不到值? php 单入口框架如何添加分页类? 周末啦,散分。。。 mysql触发器问题
{
//check to exist the file
if(file_exists($strFilePath) == false) return false;
$fpFile = fopen($strFilePath, "r");
if($fpFile == false) return false;
if($strFileName != null) {
$nFileSize = filesize($strFilePath);
if(is_null($strMimeType) == true || $strMimeType == "") $strMimeType = "application/octet-stream";
if(is_null($strMimeType) == true || $strMimeType == "") $strMimeType = "application/unknown";
Header("Content-Type: ". $strMimeType .";");
Header("Content-Disposition: attachment; filename=\"$strFileName\"");
Header("Content-Length: $nFileSize");
Header('Accept-Ranges: bytes');
Header("Cache-control: private");
Header('Pragma: private');
Header("Expires: 0");
}
fpassthru($fpFile);
return true;
}
}
或者
header()
echo file_get_contents()
--------------完美的签名线-----------------
网页游戏开发第一站 http://dev.web863.com