Forum


Replies: 3   Views: 3921
Createdocxanddownload bug
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 tthrockmorton  · 02-08-2016 - 17:45

According to the documentation on the CreateDocx::createDocxAndDownload function, it is used to download the document as an output to the browser. It does this, however, I'm noticing that a duplication bug. I've attached my code below. As you can see, I'm providing the file a name of 'Policies-YYYY-MM-DD'. This name is outputted correctly and sent to the browser. However, it is also saved into the working directory where the script was executed from. I've only been able to replicate this with this name. If I change the date to be `date('Y-m-d_h:i:s')` it does not duplicate itself. I would not want to have to change the naming format of my document generation just because it causes duplication on the server. Any thoughts as to why this is happening?

require_once 'path_to_docx/classes/CreateDocx.inc';

$docx = new CreateDocxFromTemplate('filename.docx');

$docx->replaceVariableByText(array('YEAR' => date('Y')),array('target'=>'footer'));
$filename = 'Policies-'. date('Y-m-d');
$docx->createDocxAndDownload($filename);