2
PHP에서 docx 파일을 다운로드하려면 PHPWord를 사용하고 있습니다. 그러나 다운로드하려고하면 파일에 아무것도 인쇄되지 않습니다. 그러나 내용은 서버에 저장된 파일에 표시됩니다. 아래는 내가 사용한 코드입니다. 누구든지 문제가 무엇인지 말해 줄 수 있습니까?PHPWord를 사용하여 문서에 아무 것도 인쇄되지 않습니다
<?php
include "../includes/config.inc.php";
include '../PHPWord.php';
// Create a new PHPWord Object
$PHPWord = new PHPWord();
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();
$section->addText('CANDIDATES DETAILS');
$filename='test';
$file=$filename.'.docx';
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('/form_doc/'.$filename.'.docx');
//download the file
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Disposition: attachment; filename='.$file);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
미리 감사드립니다.
감사합니다,
네하
($ file)) {{your code}'그리고 발견되지 않으면 ** 파일 경로 ** 문제가됩니다. '헤더'가 필요함 ** 전체 문서 경로 ** –
고맙습니다. –
음 ... 환영합니다. –