php自定义header,我想在PHP中使用header()自定义

站在巨人的肩膀上,我已成功使用header()拼出脚本在我的内联网上发布pdf文档,

我的显示代码:

require_once "includes/IniFile.php";

include_once "includes/process.php";

$MyData['ini'] = IniFile::getSettings();

foreach ( $_POST as $key => $value )

{ $fn = $key; }

$fn = str_replace("|sp|"," ",$fn);

$fn = str_replace("|dt|",".",$fn);

$ed = explode('!',$fn) ;

$MyData['ini']['pathMask'] = str_replace('|DEPT|', dptdir($ed[1], $MyData['ini'] ['departments']), $MyData['ini']['pathMask']);

$MyData['ini']['pathMask'] = str_replace('|FLDR|', subdir($ed[2], $MyData['ini'] ['folders']), $MyData['ini']['pathMask']);

$fn ='';

$file = $MyData['ini']['pathMask'].$ed[0];

header('Content-type: application/pdf');

header('Content-Disposition: inline; filename="'.$fn.'"');

header('Content-Transfer-Encoding: binary');

header('Content-Length: ' . filesize($file));

@readfile($file);

?>

一切运作良好,但我希望包含.pdf的新页面具有 对应于要发布的文档名称.

这可能吗?

谢谢 – 克里斯.

最佳答案 您应该呈现正常页面并将PDF嵌入到iframe中,而不是丢弃标题.通过这种方式,您可以获得标题,PDF仍然是内联的.

My great title for the PDF

html, body {

margin: 0;

padding: 0;

border: 0;

height: 100%;

overflow: hidden;

}

iframe {

width: 100%;

height: 100%;

border: 0

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值