From: Mathieu Lutfy Date: Thu, 22 Oct 2015 18:00:59 +0000 (-0400) Subject: CRM-17432 Attachment API create: use copy/unlink instead of rename(), to avoid file... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a436d0755b02225c22bad5d6cad57428f4152c09;p=civicrm-core.git CRM-17432 Attachment API create: use copy/unlink instead of rename(), to avoid file permission problems. --- diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index e8917eb483..1ae66b2651 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -160,7 +160,10 @@ function civicrm_api3_attachment_create($params) { file_put_contents($path, $content); } elseif (is_string($moveFile)) { - rename($moveFile, $path); + // CRM-17432 Do not use rename() since it will break file permissions. + // Also avoid move_uplaoded_file() because the API can use options.move-file. + copy($moveFile, $path); + unlink($moveFile); } // Save custom field to entity