Only avoid overwriting files (introduced in b159581156) if avoid_overwriting is set on the field

This commit is contained in:
Flavio Copes
2016-08-02 17:48:07 +02:00
parent acfe5e5954
commit 4a50d2f0e2
2 changed files with 5 additions and 3 deletions

View File

@@ -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

View File

@@ -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")) {