Forum


Replies: 7   Views: 4394
Permission denied when trying to delete the last merged file
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 Bouillou  · 12-05-2015 - 08:04

Here is a simple script to reproduce the problem : // Issue : the last merged file cannot be deleted require_once '../../../Classes/Phpdocx/Create/CreateDocx.inc'; $docx = new Phpdocx\Create\CreateDocxFromTemplate('testVAR.docx'); $docx->replaceVariableByText(array('VAR1' => 'OK1')); $docx->replaceVariableByText(array('VAR2' => 'OK2')); $docx->createDocx('out1'); $docx = new Phpdocx\Create\CreateDocxFromTemplate('testVAR.docx'); $docx->replaceVariableByText(array('VAR1' => 'OK1')); $docx->replaceVariableByText(array('VAR2' => 'OK2')); $docx->createDocx('out2'); $docx = new Phpdocx\Create\CreateDocxFromTemplate('testVAR.docx'); $docx->replaceVariableByText(array('VAR1' => 'OK1')); $docx->replaceVariableByText(array('VAR2' => 'OK2')); $docx->createDocx('out3'); $merge = new Phpdocx\BatchProcessing\MultiMerge(); $merge->mergeDocx('out1.docx', array('out2.docx', 'out3.docx'), 'out_final.docx', array()); unlink('out1.docx'); unlink('out2.docx'); // this file cannot be deleted : PHP Warning: unlink(out3.docx): Permission denied unlink('out3.docx'); // Test with one file to merge $merge = new Phpdocx\BatchProcessing\MultiMerge(); $merge->mergeDocx('out1.docx', array('out2.docx'), 'out_final.docx', array()); unlink('out1.docx'); // this file cannot be deleted : PHP Warning: unlink(out2.docx): Permission denied unlink('out2.docx');