mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
d02df71680
commit
5dadb5a74f
@ -1147,6 +1147,11 @@ class UploadField extends FileField {
|
|||||||
$fileObject = Object::create($relationClass);
|
$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.
|
// Get the uploaded file into a new file object.
|
||||||
try {
|
try {
|
||||||
$this->upload->loadIntoFile($tmpFile, $fileObject, $this->getFolderName());
|
$this->upload->loadIntoFile($tmpFile, $fileObject, $this->getFolderName());
|
||||||
|
Loading…
Reference in New Issue
Block a user