Default UploadField to replace files

Honours the $overwriteWarning setting, rather than warning
about overwritten files, and when that warning is acknowledged by the user,
create a new file instead. We need to set this as close to
the Upload->load() call as possible, since it depends
on non-deterministic config state.
This commit is contained in:
Ingo Schommer 2013-10-23 23:00:31 +02:00
parent d02df71680
commit 5dadb5a74f

View File

@ -1147,6 +1147,11 @@ class UploadField extends FileField {
$fileObject = Object::create($relationClass);
}
// Allow replacing files (rather than renaming a duplicate) when warning about overwrites
if($this->getConfig('overwriteWarning')) {
$this->upload->setReplaceFile(true);
}
// Get the uploaded file into a new file object.
try {
$this->upload->loadIntoFile($tmpFile, $fileObject, $this->getFolderName());