Force file download PDF 'open with' box says its a Firefox document ??

我的未来我决定 提交于 2020-01-03 03:03:31

问题


I am trying to force download a PDF file, Everything works fine. Only problem is when it show a "Download box" it says its a "Firefox Document" which actually should say "Adobe Acrobat Document". See the images, and below is the code i am using

1) Force download box from gmail, which works fine

2) Force download box from my application, which says "Firefox Document"

  header("Pragma: public"); 
  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
  header("Content-Type: application/pdf"); 
  header("Content-Disposition: attachment; filename=\"".basename($file)."\";" ); 
  header("Content-Transfer-Encoding: binary"); 
  header("Content-Length: ".filesize(getcwd().$file)); 

  readfile(getcwd().$file); 

回答1:


for everyone who is searching for the same issue.

the TS go the solution :

add exit @ the end (for some reasons firefox needs this)

header("Content-Type: application/pdf");
echo $pdf;
exit;



回答2:


Try to use

Header('Content-Type: application/octet-stream');

instead of

Header("Content-Type: application/pdf"); 


来源:https://stackoverflow.com/questions/16515046/force-file-download-pdf-open-with-box-says-its-a-firefox-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!