【问题标题】:PHP Help - MIME Code?PHP 帮助 - MIME 代码?
【发布时间】:2012-03-22 21:51:49
【问题描述】:

我想使用 MIME 代码下载完整的网页。我正在使用

header("Content-type:application/msword");
header("Content-Disposition:attachment; Filename=$profile_id.doc");

在 MS Word 中下载网页,我正在尝试:

header("Content-type:application/pdf");
header("Content-Disposition:attachment; Filename=$profile_id.pdf");

以 PDF 格式下载网页,但 PDF 格式的网页不起作用。请告诉我该怎么做...谢谢:)

我认为该代码现在已被弃用。请告诉我这个的替代代码

【问题讨论】:

  • 你的问题到底是什么?您是否正确输出了 pdf 二进制流?
  • Jerome...不,先生,如果是 PDF 文件,我没有得到正确的输出...文件已下载但格式不正确..所以它无法在 Acrobat Reader 中打开

标签: php mime


【解决方案1】:

试试:

header('Content-Type:application/pdf'); header('Content-Disposition:attachment; filename="'.$profile_id.'.pdf"');

已编辑: 试试,比如:

$file = $profile_id.".pdf"; header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Type: application/octetstream'); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize($file)); header('Content-Disposition:attachment; filename="'.$profile_id.'.pdf"');

【讨论】:

  • @OP:是的,或者将变量包装在 {} 中,以便解析器可以看到哪些位是变量:)
  • Sudhir 先生...我试过了... header("Content-Disposition:attachment; Filename=$profile_id.pdf");工作正常但不是“header('Content-Type:application/pdf');”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多