예제 #1
0
 /**
  * Allows to upload files defined in picture object.
  * @param Picture $picture
  */
 private function processUpload($picture)
 {
     $relativeFolderPath = $this->container->getParameter('jc_slideshow.root_path') . '/slideshow_' . $picture->getSlideshow()->getId();
     $absoluteFolderPath = $this->container->getParameter('kernel.root_dir') . '/../web' . $relativeFolderPath;
     // Create folder if necessary
     if (!is_dir($absoluteFolderPath)) {
         mkdir($absoluteFolderPath);
     }
     // If main picture is defined => process upload
     if (null !== $picture->getPictureFile()) {
         $pictureName = $picture->getPictureFile()->getClientOriginalName();
         // Move file in userfiles folder + save new URL
         $picture->getPictureFile()->move($absoluteFolderPath, $pictureName);
         $picture->setPictureUrl($relativeFolderPath . '/' . $pictureName);
     }
 }