diff --git a/src/Element/Upload.php b/src/Element/Upload.php index 8f39ff6..eb6875e 100644 --- a/src/Element/Upload.php +++ b/src/Element/Upload.php @@ -21,7 +21,7 @@ class Upload extends FileElement { $info = parent::getInfo(); $info['#required'] = FALSE; - $info['#upload_location'] = 'public://'; + $info['#upload_location'] = 'public://'.date('Y').'-'.date('m').'/'; $info['#upload_validators'] = []; $info['#element_validate'] = [ [static::class, 'validate'], @@ -95,7 +95,7 @@ class Upload extends FileElement { $upload = \Drupal::request()->files->get($id); if ($upload instanceof UploadedFile) { - $destination = $file_system->realPath($element['#upload_location']); + $destination = $element['#upload_location']; $name = file_munge_filename($upload->getClientOriginalName(), NULL); // Support both Drupal 8.7's FileSystemInterface API, and its earlier diff --git a/src/Plugin/EntityBrowser/Widget/FileUpload.php b/src/Plugin/EntityBrowser/Widget/FileUpload.php index 035d744..8ffe6fc 100644 --- a/src/Plugin/EntityBrowser/Widget/FileUpload.php +++ b/src/Plugin/EntityBrowser/Widget/FileUpload.php @@ -60,6 +60,7 @@ class FileUpload extends EntityFormProxy { '#process' => [ [$this, 'processUploadElement'], ], + '#upload_location' => 'public://'.date('Y').'-'.date('m').'/', '#upload_validators' => $this->getUploadValidators(), '#weight' => 70, ];