DocxMerge icon indicating copy to clipboard operation
DocxMerge copied to clipboard

Permissions issue with PHP rename() function.

Open JamieWritesCode opened this issue 8 years ago • 1 comments

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?

JamieWritesCode avatar Jul 07 '16 03:07 JamieWritesCode

Thank you @TehCrucible . @krustnic you should update that!

souhailmerroun avatar May 29 '17 04:05 souhailmerroun