|
@@ -98,10 +98,8 @@ trait UploadField
|
|
|
*/
|
|
|
public function renameIfExists(UploadedFile $file)
|
|
|
{
|
|
|
- if ($this->getStorage()->exists("{$this->getDirectory()}/$this->name") && ! $this->options['override']) {
|
|
|
+ if ($this->getStorage()->exists("{$this->getDirectory()}/$this->name")) {
|
|
|
$this->name = $this->generateUniqueName($file);
|
|
|
- } else {
|
|
|
- $this->getStorage()->delete("{$this->getDirectory()}/$this->name");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -196,6 +194,10 @@ trait UploadField
|
|
|
|
|
|
$this->name = $this->getStoreName($file);
|
|
|
|
|
|
+ if ($this->options['override']) {
|
|
|
+ $this->remove();
|
|
|
+ }
|
|
|
+
|
|
|
$this->renameIfExists($file);
|
|
|
|
|
|
$this->prepareFile($file);
|
|
@@ -218,6 +220,13 @@ trait UploadField
|
|
|
throw new UploadException(trans('admin.uploader.upload_failed'));
|
|
|
}
|
|
|
|
|
|
+ public function remove()
|
|
|
+ {
|
|
|
+ if ($this->getStorage()->exists("{$this->getDirectory()}/$this->name")) {
|
|
|
+ $this->getStorage()->delete("{$this->getDirectory()}/$this->name");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param UploadedFile $file
|
|
|
*/
|