![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/CoreBundle/Helper/ |
<?php namespace Mautic\CoreBundle\Helper; use Mautic\CoreBundle\Exception\FilePathException; use Mautic\CoreBundle\Exception\FileUploadException; use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\UploadedFile; class FileUploader { public function __construct( private FilePathResolver $filePathResolver ) { } /** * @param string $uploadDir * * @return string * * @throws FileUploadException */ public function upload($uploadDir, UploadedFile $file) { try { $fileName = $this->filePathResolver->getUniqueFileName($uploadDir, $file); $this->filePathResolver->createDirectory($uploadDir); try { $file->move($uploadDir, $fileName); return $fileName; } catch (FileException) { throw new FileUploadException('Could not upload file'); } } catch (FilePathException $e) { throw new FileUploadException($e->getMessage()); } } /** * @param string $path */ public function delete($path): void { $this->filePathResolver->delete($path); } }