作者angelmark (湖畔风晴)
看板PHP
标题[请益] 使用header下载MP3 档案都只有0K
时间Thu Sep 22 11:01:53 2011
各位大大
不好意思小弟又有问题要问了
在网路上找了很多header下载MP3的方法
但是不管怎样下载下来的资料都是 0 K
希望各位大大能够帮帮小弟是不是程式码哪边写错了
程式码如下:
$filename="back.mp3";
$myfile = "/home/httpd/html/www.xxx.com/test/back.mp3";
$mm_type = "application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
这一段改写成这样结果也一样
header("Content-Length: " .filesize($myFile));
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
readfile($myFile);
希望各位大大帮我看看是不是哪边有问题
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.81.19.118
※ 编辑: angelmark 来自: 219.81.19.118 (09/22 11:03)
※ 编辑: angelmark 来自: 219.81.19.118 (09/22 11:42)
1F:→ rocet:先确认 filesize($myFile) 的值正不正确 09/22 13:07
2F:→ AndCycle:大小写错误, myfile myFile 09/24 15:53
3F:→ dlikeayu:开发时常有这问题,本身很喜欢用笔记本写,後来放弃了 09/25 07:34
4F:→ dlikeayu:有侦错工具真的事半功倍 09/25 07:34