<?php namespace App\Service; use Symfony\Component\HttpFoundation\File\UploadedFile; class FileUploader { private $targetDir; public function __construct($targetDir) { $this->targetDir = $targetDir; } public function upload(UploadedFile $file) { $fileName = $file->getClientOriginalName(); $file->move($this->getTargetDir(), $fileName); return $fileName; } public function getTargetDir() { return $this->targetDir; } }