简体   繁体   English

PHP force_download 正在下载指定文件名的文件,但将其称为“file.pdf”

[英]PHP force_download is downloading file with filename specified but calling it 'file.pdf'

I am using force_download and everything works well except for the file being named 'file.pdf' and not 'Daily_delivery_sheet.pdf'.我正在使用 force_download,除了名为“file.pdf”而不是“Daily_delivery_sheet.pdf”的文件之外,一切都运行良好。 The pdf looks correct, it's just the filename that is wrong. pdf看起来正确,只是文件名错误。 I am stumped as to why this is happening.我很困惑为什么会这样。

In the next function in the same file, the code is exactly the same and it is working perfectly.在同一文件中的下一个函数中,代码完全相同,并且运行良好。

Here is my code:这是我的代码:

$pdf = $mcccpdf->getPdf($data);
$this->load->helper('download');
$filename = 'Daily_delivery_sheet.pdf';
force_download($filename, $pdf);
exit;

It turns out that another programmer put $pdfobj->ezStream( array('compress' => 0 ) );原来另一个程序员把$pdfobj->ezStream( array('compress' => 0 ) ); where the PDF was being generated and that was the cause of the problem.生成 PDF 的位置,这就是问题的原因。 I removed it and everything works perfectly now.我删除了它,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM