From b31c97fd0870efd11062ffde16d94c0836752af7 Mon Sep 17 00:00:00 2001 From: Volmarg Date: Fri, 1 Nov 2019 09:14:18 +0100 Subject: [PATCH] Bugfix: tags were set incorrectly --- src/Services/FileUploader.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Services/FileUploader.php b/src/Services/FileUploader.php index 8ddb3e51..ea08bb9e 100755 --- a/src/Services/FileUploader.php +++ b/src/Services/FileUploader.php @@ -119,19 +119,21 @@ public function upload(UploadedFile $file, Request $request, string $type, strin $extension = $extension ?: $file_extension; $filename = $filename ?: $original_filename; + # check if the target folder is main folder + if ( !empty($subdirectory) && $subdirectory !== $target_directory ) { + $target_directory .= DIRECTORY_SEPARATOR . $subdirectory; + } + $file_full_path = $target_directory . DIRECTORY_SEPARATOR . $filename . DOT . $extension; if (file_exists($file_full_path)) { - $filename .= '_' . $now->format('Y_m_d_H_i_s_u') . DOT . $extension; + $filename .= '_' . $now->format('Y_m_d_H_i_s_u'); $file_full_path = $target_directory . DIRECTORY_SEPARATOR . $filename . DOT . $extension; } - # check if the target folder is main folder - if ( !empty($subdirectory) && $subdirectory !== $target_directory ) { - $target_directory .= '/' . $subdirectory; - } + $filename_with_extension = $filename . DOT . $extension; try { - $file->move($target_directory, $filename); + $file->move($target_directory, $filename_with_extension); if( !empty($tags) ){ $this->files_tags_controller->updateTags($tags, $file_full_path);