作者jai166 (EricYang)
看板PHP
标题[请益] header()
时间Wed Mar 15 09:12:22 2006
我是用Discuz!做的
因为网站能使用的记忆体只有8MB
当传送超过8MB的档案时会出现问题(下载的档案为0位元组)
我试着修改attachment.php
header('Cache-control: max-age=31536000');
header('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 31536000).' GMT');
header('Content-Encoding: none');
//header('Content-Length: '.$filesize);
//forbid flash be opened directly
//header('Content-Disposition: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')
? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);
header('Content-Disposition: attachment; filename='.$attach['filename']);
header('Content-Type: '.$attach['filetype']);
@$fp = fopen($filename, 'rb');
@flock($fp, 2);
$attachment = @fread($fp, $filesize);
@fclose($fp);
echo $attachment;
就将,後来我试着用Location的方式,改成下面的样子
if ( $filesize > 8388608 ){
header('Location: attachments/'.$attach['attachment']);
}else{
header('Cache-control: max-age=31536000');
header('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 31536000).' GMT');
header('Content-Encoding: none');
//header('Content-Length: '.$filesize);
//forbid flash be opened directly
//header('Content-Disposition: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')
? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);
header('Content-Disposition: attachment; filename='.$attach['filename']);
header('Content-Type: '.$attach['filetype']);
@$fp = fopen($filename, 'rb');
@flock($fp, 2);
$attachment = @fread($fp, $filesize);
@fclose($fp);
echo $attachment;
}
if(!$isimage) {
updatecredits($discuz_uid, $creditspolicy['getattach'], -1);
}
会变成一个充满乱码的页面,我试着在前面在加入表头
if ( $filesize > 8388608 ){
header('Content-Disposition: attachment; filename='.$attach['filename']);
header('Content-Type: '.$attach['filetype']);
header('Location: attachments/'.$attach['attachment']);
}else{
结果是
无法显示 XML 网页
无法使用 样式表检视 XML 输入。请更正错误,然後按 重新整理按钮,或者稍後再试一
次。
--------------------------------------------------------------------------------
文字内容包含无效的字元。处理资源
'
http://localhost/Discuz/upload/attachments/forumid_1/ACD%20Systems2_1WONay4mpVBR.rar'
发生错误。
但我按右键检视原始码时,出现的内容是要下载的档案,而且网址也没问题
有办法改好吗??
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.203.192.14