DocxMerge
DocxMerge copied to clipboard
Permissions issue with PHP rename() function.
Hi mate, getting an 'Operation not permitted' warning with the use of the PHP rename function in src/DocxMerge/Docx.php
on line 131. Running Ubuntu 14.04 with PHP7.
// Replace current file with tempFile content
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
copy( $tempFile, $this->docxPath );
}
else {
rename($tempFile, $this->docxPath);
}
I've temporarily fixed it by copying then unlinking rather than using replace, similar to what you've done for Windows. Any reason why we can't just use copy and unlink for both like so?
// Replace current file with tempFile content
if ( copy($tempFile, $this->docxPath) ) {
unlink($tempFile);
}
Happy to create a PR if necessary. Unless I'm missing some particular reason to use rename?
Thank you @TehCrucible . @krustnic you should update that!