【发布时间】:2015-02-23 02:32:54
【问题描述】:
你能告诉我我的标题有什么问题吗?我的下载工作正常。我使用 PHPWord 库,但我认为问题出在标题上。
<?php
require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$wordText = utf8_encode($_REQUEST['TEXT']);
$section->addText($wordText);
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
//$objWriter->save('helloWorld.docx');
$path = 'tmp/kikou2.docx';
$objWriter->save($path);
//download code
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$path);
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($path));
flush();
readfile($path);
unlink($path);
exit();
?>
下载后,我得到的文件内容如下:
PK#######tJWF90�G�;##&J?J�wr��v###���@��#�##b�����g�e�E�/Mw��gS�l��#��-�����2�#\#�"n5��G�W�G�|#X+# \��B��Ks��#�#@��[��y�7�����j��Êh�|#BA�^#49j�[��Gv�#��#��#�#z>짙C���v)�� ��_��#��
【问题讨论】: