getClientOriginalName(), PATHINFO_FILENAME); $safeFilename = $this->slugger->slug($originalFilename); $fileName = $safeFilename . '-' . uniqid() . '.' . $file->guessExtension(); try { $file->move($this->getTargetDirectory(), $fileName); } catch (FileException $e) { // ... handle exception if something happens during file upload } return $fileName; } public function deleteFile(string $filepath): bool { if (!$filepath || !is_file($filepath)) { return false; } $deleted = unlink($filepath); return $deleted; } public function getTargetDirectory(): string { return $this->targetDirectory; } }