Im using PHPWord to make a document from a template, its all worked great so far and the documentation is fairly decent: http://phpword.readthedocs.org/en/latest/index.html
But I cannot open the file that I have created, using:
$templateProcessor->saveAs($filename);
It says word cannot open as user does not have access privileges. I don't see anything in the documentation about this and searching SO finds several other similar questions all unanswered.
Anyone have any ideas on this?
Ok I worked it out. Thanks to @John Smith for helping to steer me in the right direction. I found the answer here: https://github.com/PHPOffice/PHPWord/issues/532
Basically i changed the function saveAs from:
rename($tempFilename, $strFilename);
to:
copy($tempFilename, $strFilename);
unlink($tempFileName);
and it now works a dream. Thanks again @John Smith for the help.
You can do this manually I think : http://php.net/manual/en/function.chmod.php
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);