2012-03-05 53 views
0

我想使用MIME代码下载完整的网页。我使用PHP帮助 - 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一个不工作。请告诉我该怎么做......谢谢:)

我认为现在这个代码已经被弃用了。请让我知道TH这

+0

http://stackoverflow.com/questions的可能的复制/ 312230 /适当的mime-type-for-pdf-files – rkosegi 2012-03-05 12:15:07

+0

你的问题到底是什么?你正确输出一个pdf二进制流? – 2012-03-05 12:15:52

+0

杰罗姆...没有先生,我没有得到正确的输出PDF文件的情况下......文件被下载,但格式不正确,所以它不在Acrobat Reader中打开 – 2012-03-05 12:18:03

回答

0

尝试替代代码:

 

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"'); 

 
+0

@OP:是,或包装在{}中的变量,所以解析器可以看到哪些位意味着变量:) – halfer 2012-03-05 12:18:58

+0

Sudhir先生...我试过了... header(“Content-Disposition:attachment; Filename = $ profile_id.pdf” ); 正常工作,但不是 “header('Content-Type:application/pdf');” – 2012-03-05 12:22:10

+0

看到编辑过的部分,希望它能正常工作 – 2012-03-05 12:27:56