作者SyaoranX (小狼)
看板PHP
标题[请益] Header 无法下载wma的问题
时间Tue Feb 8 22:06:31 2011
大家好,爬了版上跟google了一些header的用法。不过我在下载pdf档案都没问题
虽独wma档会出现下载0k的档案这种情况,不知道有没有人碰过@@?
我的程式如下:
法一:
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=$file");
法二:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
法三:
这个方法我有手动指定Content-Type
wma的type是用audio/x-ms-wma 不知有没有错~"~
header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
header('Pragma: no-cache');
header('Content-Encoding: none');
header('Content-Disposition: '.'attachment'.'; filename='.$file_name);
header('Content-type: '.$file_type);
header('Content-Length: '.filesize( $file_path_on_server ));
$downcontent=file_get_contents( $file_path_on_server );
echo $downcontent;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.122.184.111
※ 编辑: SyaoranX 来自: 140.122.184.111 (02/08 22:08)