普通下载
header('content-type:text/html;charset=utf-8');//接收文件路径
$path = $_GET['path'];
$filename = substr($path,strrpos($path,"/")+1);
//文件类型
header('Content-type: image/pjpeg');
//激活一个下载的窗口 (文件名)
header("Content-Disposition: attachment; filename=$filename");
//读文件
readfile($path);
TP下载
//获取要下载的文件id$sid=$_GET['sid'];
//查找文件路径
$obj=M('song');
$spath=$obj->where("s_id=$sid")->find();
$path = "./Public/".$spath['s_path'];
$filename = substr($path,strrpos($path,"/")+1);
//文件类型
header('Content-type: mp3/mp4');
//激活一个下载的窗口 (文件名)
header("Content-Disposition: attachment; filename=$filename");
//读文件
readfile($path);