Forum


Replies: 8   Views: 6180
Phpdocx 2.5 installation problem
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jc.021286  · 11-04-2013 - 12:13

Regarding the Issue with the file being corrupt. After searching, I found that there is supposedly extra html or php headers being appended to the end of the document.

The workaround that others found and posted is as follows,

[code]
/*
* Old code that was working but gave corrupt file that had to be recovered.
*/
//$docx->createDocx('../phpdocx/phpdocx_pro/Output/MPS_Assessment');
//$docx->createDocxAndDownload('../phpdocx/phpdocx_pro/Output/test');


$filename = '../phpdocx/phpdocx_pro/Output/test';//<< My document is going to be called Test and placed in a directory.
$docx->createDocx($filename);//<< Create my Document
unset($docx);
header("Content-Type: application/vnd.ms-word");
header("Content-Length: ".filesize($filename.'.docx'));
header('Content-Disposition: attachment; filename=MPS_Assessment.docx');
header('Content-Transfer-Encoding: binary');
ob_clean();
flush();
readfile($filename.'.docx');//<< Sends the file to the user for download
unlink($filename.'.docx');//<< removes the file from the server for security reasons, comment out to keep if you want to retain a copy.
exit;//<< REQUIRED TO STOP THE ANNOYING CORRUPT NOTICE
[/code]

Hope this helps you out, all credit to the original writers that posted over on stackoverflow
jc