Ejemplo n.º 1
0
 public function companyGalleryImageUploadAction(Request $request)
 {
     $to_json = [];
     $em = $this->getDoctrine()->getManager();
     $user = $this->getUser();
     $image_id = array();
     $image_src = array();
     $i = 0;
     if (!$user) {
         return new JsonResponse($to_json);
     }
     foreach ($request->files as $file) {
         $file_name = sha1(uniqid()) . '.' . $file->guessExtension();
         $image = new Gallery();
         $image->setFileName($file_name);
         $file->move($image->getAbsolutePath(), $image->getFileName());
         $em->persist($image);
         $em->flush();
         $em->refresh($image);
         $image_id = $image->getId();
         $image_src = $image->getSrc();
         $to_json[$i] = ['filelink' => $this->get('liip_imagine.cache.manager')->getBrowserPath($image_src, 'profile_inset'), 'imageId' => $image_id];
         $i++;
     }
     return new JsonResponse($to_json);
 }
Ejemplo n.º 2
0
 /**
  * @Route("/employer/addImageToGallery", name="employer_add_image_to_gallery")
  * @Template()
  */
 public function addImageToGalleryAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $employer = $this->getUser();
     $company = $employer->getCompany();
     if ($company) {
         $fileG = $request->files->get('fileG');
         foreach ($fileG as $file) {
             if ($file->guessExtension() == "jpeg" || $file->guessExtension() == "jpg" || $file->guessExtension() == "png") {
                 $file_name = sha1(uniqid()) . '.' . $file->guessExtension();
                 $image = new Gallery();
                 $image->setFileName($file_name);
                 $image->setCompany($company);
                 $file->move($image->getAbsolutePath(), $image->getFileName());
                 $em->persist($image);
                 $em->flush();
                 $em->refresh($image);
             }
         }
     }
     return $this->redirectToRoute('employer_company', array(), 301);
     //        return  $this->render('MainBundle:Employer:companyEmployer.html.twig' , ["countries" => $countries , "company" => $company , "branches" => $branches , "notify" => $notify]);
 }