diff --git a/CHANGELOG.md b/CHANGELOG.md index 314e509d..659542a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * Fixed issue in `selfupgrade` where the package would get downloaded in the wrong destination * Hide tab when user is not authorized to access it [#712](https://github.com/getgrav/grav-plugin-admin/issues/712) * Fixed Lists issue when reindexing, causing Radio fields to potentially lose their `checked` status - * Avoid overwriting a file when uploaded with the same filename through the Admin blueprint `file` type + * Avoid overwriting a file when uploaded with the same filename through the Admin blueprint `file` field type if `avoid_overwriting` is enabled on the field # v1.1.2 ## 07/16/2016 diff --git a/classes/controller.php b/classes/controller.php index 1262531c..dbbda0c0 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -1351,8 +1351,10 @@ class AdminController Folder::mkdir($resolved_destination); } - if (file_exists("$resolved_destination/$name")) { - $name = date('YmdHis') . '-' . $name; + if (isset($field['avoid_overwriting']) && $field['avoid_overwriting'] === true) { + if (file_exists("$resolved_destination/$name")) { + $name = date('YmdHis') . '-' . $name; + } } if (move_uploaded_file($tmp_name, "$resolved_destination/$name")) {