+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @see Civi\API\Subscriber\DynamicFKAuthorization
*/
function civicrm_api3_attachment_create($params) {
-
if (empty($params['id'])) {
- // When creating we need either entity_table or field_name
+ // When creating we need either entity_table or field_name.
civicrm_api3_verify_one_mandatory($params, NULL, array('entity_table', 'field_name'));
}
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