Answer the question
In order to leave comments, you need to log in
Why is PHPWord giving a broken file?
Good evening. I am using the following code to populate a file using PHPWord in yii2 on Ubuntu:
$PhpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $PhpWord->loadTemplate('/var/www/basic/web/Dogovor.docx'); //шаблон
$document->setValue('company_name', $_POST['News']['title'] );
$document->setValue('worker', $_POST['News']['text']);
header("Content-Type:application/vnd.ms-office");
header('Cache-Control: max-age=0');
header('Content-Disposition: attachment;filename="Dogovor.docx"');
$document->saveAs('php://output');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question