diff --git a/src/Controller/TinyPNGBackendController.php b/src/Controller/TinyPNGBackendController.php index 7e7aff0..731da59 100644 --- a/src/Controller/TinyPNGBackendController.php +++ b/src/Controller/TinyPNGBackendController.php @@ -181,7 +181,7 @@ public function allImages( Application $app, Request $request, $directory ) protected function getAllDirectories( $app, $fileList ) { - $filesystem = $this->fsSetup( $app ); + $filesystem = $this->fsSetup( $app ); $files = []; @@ -637,7 +637,8 @@ public function uploadImage( Application $app, Request $request, $directory ) if ( $fileExists ) { $fileParts = pathinfo( $fileName ); $normalizedFilename = $this->normalizeFileName( $fileName ); - $newName = $this->renameExisting( $normalizedFilename, $uploadDir, $fileParts['extension'] ); + $newName = $this->renameExisting( $normalizedFilename, $uploadDir, + $fileParts['extension'] ); } else { $newName = $this->normalizeFileName( $fileName ); } @@ -712,8 +713,8 @@ private function normalizeFileName( $filename ) */ private function renameExisting( $normalizedName, $directory, $extension ) { - $parts = pathinfo($normalizedName); - $fileName = isset( $directory ) + $parts = pathinfo( $normalizedName ); + $fileName = isset( $directory ) ? $directory . $parts['filename'] : $parts['filename'];