作者saponevol23 (saponevol23)
看板PHP
标题[请益] 使用header下载的档案与原档不一样
时间Sat Dec 3 21:34:53 2011
程式码如下:
header("Content-type: ".filetype("$file"));
header("Content-Disposition: attachment; filename=".$filename."");
readfile($file);
$file为档案路径
$filename是要下载的档案名称
假设现在下载一个txt档
下载下来的文件内容在开头的地方会比原来多一个0
ex:
a.txt档内容是"9 5 8 7 17 6"
下载下来的档案内容会变成"09 5 8 7 17 6"
其他的档案像是rar或图片都会损坏
不知道怎麽改才好 有请了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.255.181.58
1F:→ alpe:程式没错... 至少这部份 12/03 22:42
2F:→ poi987poi987:程式开头有输出东西吧.类似BOM 12/04 01:59
3F:→ poi987poi987:通常写这样有输出的东西会加入下载档案中 12/04 02:02