Skip to content

Commit

Permalink
Bugfix: tags were set incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
Volmarg committed Nov 1, 2019
1 parent 611be1b commit b31c97f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Services/FileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b31c97f

Please sign in to comment.