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 数据显示Resource id #4 php使用GD库加文字水印如何实现换行 请就高手循环写入数据库的 方法 求推荐PHP书籍! php 删除文件问题 TP的关联模型... 在linux服务器下SQLITE数据库无法使用 请教:如何去掉"\n"换行符 PHP关于REQUEST一点问题 请问怎么将数据添加进数据库中? 周末啦,散分。。。 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