src/Controller/AjaxController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\RealisationRepository;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpKernel\Kernel;
  8. use Symfony\Component\HttpKernel\KernelInterface;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class AjaxController extends AbstractController
  11. {
  12. /**
  13. * @Route("/realisation/more", name="realisationAjax")
  14. */
  15. public function realisationMore(RealisationRepository $realisationRepository,Request $request): Response
  16. {
  17. $realisation = $realisationRepository->find($request->get('realisation'));
  18. return $this->render('ajax/realisation.html.twig', [
  19. 'realisation' => $realisation
  20. ]);
  21. }
  22. /**
  23. * @Route("/imagesPost", name="imagePost")
  24. */
  25. public function imagePost(Request $request,KernelInterface $kernel): Response
  26. {
  27. $image = $kernel->getProjectDir().'/public/' .$request->get("key");
  28. if (move_uploaded_file($_FILES['file']['tmp_name'], $image)) {
  29. $mess = "File is valid, and was successfully uploaded.\n";
  30. } else {
  31. $mess = "Possible file upload attack!\n";
  32. }
  33. return new Response($mess);
  34. }
  35. }