作者cyril63 (You belong to me)
看板PHP
标题[请益] download file
时间Thu Jun 22 10:59:04 2006
以下download 档案程式码
其中
$file_dir => download file 的路径
$d_file_name => download file 的档案名称(不含路径)
if(!$fdl=@fopen($file_dir,'r'))
{
die("Cannot Open File!");
}
else
{
header("Cache-Control: ");# leave blank to avoid IE errors
header("Pragma: ");# leave blank to avoid IE errors
header("Content-type: application/X-MS-Excel");
header("Content-Disposition: attachment;filename=\"".$d_file_name."\"");
header("Content-length:".(string)(filesize($file_dir)));
sleep(1);
fpassthru($fdl);
}
问题是
执行的时候都会去download 成 这个php的名字
而不是 down file 的名字
(ex. 若这个phe script 是 down.php ,要download的名称是test.xls
预计的情况应该是 download test.xls ,但实际上是down.php 而内容都是
test.xls的内容 只是档名的问题 )
请问这是什麽状况 ? 该如何解决呢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.163.20