public function indexAction(Request $request)
    {

        $video = new Video();
        $form = $this->createForm(VideoForm::class, $video);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            $file = $video->getFile();

            // Generate a unique name for the file before saving it
            $fileName = $this->getPlayer()->getIdPlayer() . '_' . strtotime(date('Y-m-d H:i:s')) . '.' . $file->guessExtension();

            // Move the file to the directory where brochures are stored
            $file->move(
                $this->getParameter('videogamesrecords_video.path.file_in'),
                $fileName
            );

            $video->setPlayer($this->getPlayer());
            $video->setFileIn($fileName);

            $em->persist($video);
            $em->flush();

            //----- Message
            $this->addFlash(
                'notice',
                'Your video was send to the server'
            );

            //----- Redirect
            return $this->redirectToRoute('vgr_video_form_index');
        }

        return $this->render(
            'VideoGamesRecordsVideoBundle:Form:index.html.twig',
            [
                'form'  => $form->createView(),
            ]
        );
    }
public function indexAction(Request $request)
    {

        $video = new Video();
        $form = $this->createForm(VideoForm::class, $video);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            $file = $video->getFile();

            // Generate a unique name for the file before saving it
            $fileName = $this->getPlayer()->getIdPlayer() . '_' . strtotime(date('Y-m-d H:i:s')) . '.' . $file->guessExtension();

            // Move the file to the directory where brochures are stored
            $file->move(
                $this->getParameter('videogamesrecords_video.path.file_in'),
                $fileName
            );

            $video->setPlayer($this->getPlayer());
            $video->setFileIn($fileName);

            $em->persist($video);
            $em->flush();

            //----- Message
            $this->addFlash(
                'notice',
                'Your video was send to the server'
            );

            //----- Redirect
            return $this->redirectToRoute('vgr_video_form_index');
        }

        return $this->render(
            'VideoGamesRecordsVideoBundle:Form:index.html.twig',
            [
                'form'  => $form->createView(),
            ]
        );
    }
@Route("/index", requirements={"id": "[1-9]\d*"}, name="vgr_video_form_index")
@Method({"GET","POST"})
@Cache(smaxage="10")
@Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")

@param Request $request
@return \Symfony\Component\HttpFoundation\Response