【发布时间】:2014-11-11 07:58:48
【问题描述】:
我想在提交后强制下载(使用 PhpWord 生成的 .docx 文件),同时重定向到另一个页面。
这里是生成 DOCX 文件的代码:
$objWriter->save($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
header('Location: http://localhost/contracto_0.4/index.php/contrac)
readfile($filename);
unlink($filename); // deletes the temporary file
在此之后,我尝试加载一个视图,我收到了来自 PHP 的这条消息:
Cannot modify header information - headers already sent by (output started at C:\wamp\www\contracto_0.5\system\core\Exceptions.php:185)
【问题讨论】:
标签: php codeigniter