@@ -120,6 +120,7 @@ Finally, you need to update the code of the controller that handles the form::
120120 use App\Entity\Product;
121121 use App\Form\ProductType;
122122 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
123+ use Symfony\Component\DependencyInjection\Attribute\Autowire;
123124 use Symfony\Component\HttpFoundation\File\Exception\FileException;
124125 use Symfony\Component\HttpFoundation\File\UploadedFile;
125126 use Symfony\Component\HttpFoundation\Request;
@@ -130,7 +131,11 @@ Finally, you need to update the code of the controller that handles the form::
130131 class ProductController extends AbstractController
131132 {
132133 #[Route('/product/new', name: 'app_product_new')]
133- public function new(Request $request, SluggerInterface $slugger, string $brochuresDirectory): Response
134+ public function new(
135+ Request $request,
136+ SluggerInterface $slugger,
137+ #[Autowire('%kernel.project_dir%/public/uploads/brochures')] string $brochuresDirectory
138+ ): Response
134139 {
135140 $product = new Product();
136141 $form = $this->createForm(ProductType::class, $product);
@@ -171,17 +176,6 @@ Finally, you need to update the code of the controller that handles the form::
171176 }
172177 }
173178
174- Now, create the ``brochures_directory `` parameter that was used in the
175- controller to specify the directory in which the brochures should be stored:
176-
177- .. code-block :: yaml
178-
179- # config/services.yaml
180-
181- # ...
182- parameters :
183- brochures_directory : ' %kernel.project_dir%/public/uploads/brochures'
184-
185179There are some important things to consider in the code of the above controller:
186180
187181#. In Symfony applications, uploaded files are objects of the
0 commit comments