From a436d0755b02225c22bad5d6cad57428f4152c09 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 22 Oct 2015 14:00:59 -0400 Subject: [PATCH] CRM-17432 Attachment API create: use copy/unlink instead of rename(), to avoid file permission problems. --- api/v3/Attachment.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.25.1