From 6e95014c1f98ca0042d123c36c71d22340eed9f6 Mon Sep 17 00:00:00 2001 From: Joris Vaesen Date: Thu, 11 Feb 2016 19:47:32 +0100 Subject: [PATCH] fix filename when renaming through nameCallback --- src/Model/Behavior/UploadBehavior.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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']);