I'm trying to create a service to upload a file and I'm calling ContainerInterface but I got the error no such service File Uploader Service:
<?php
namespace App\Service;
//use Symfony\Component\DependencyInjection\ContainerBuilder;
//use Psr\Container\ContainerInterface as ContainerInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FileUploader{
private $container;
/**
* @var ContainerInterface
*/
public function __construct(ContainerInterface $container)
{
$this->container=$container;
}
public function uploadFile(UploadedFile $file){
$filename=md5(uniqid()).'.'.$file->guessClientExtension();
$file->move(
$this->container->getParameter('uploads_dir'),$filename
);
return $filename;
}
}