diff --git a/src/Model/Behavior/UploadBehavior.php b/src/Model/Behavior/UploadBehavior.php index adbd85f6..9d8c8d78 100644 --- a/src/Model/Behavior/UploadBehavior.php +++ b/src/Model/Behavior/UploadBehavior.php @@ -77,6 +77,8 @@ public function beforeSave(Event $event, Entity $entity, ArrayObject $options) $data = $entity->get($field); $path = $this->getPathProcessor($entity, $data, $field, $settings); $basepath = $path->basepath(); + $filename = $path->filename(); + $data['name'] = $filename; $files = $this->constructFiles($entity, $data, $field, $settings, $basepath); $writer = $this->getWriter($entity, $data, $field, $settings); @@ -86,7 +88,7 @@ public function beforeSave(Event $event, Entity $entity, ArrayObject $options) return false; } - $entity->set($field, $path->filename()); + $entity->set($field, $filename); $entity->set(Hash::get($settings, 'fields.dir', 'dir'), $basepath); $entity->set(Hash::get($settings, 'fields.size', 'size'), $data['size']); $entity->set(Hash::get($settings, 'fields.type', 'type'), $data['type']);