public function uploadAction(Request $request)
 {
     $isAjax = $request->isXmlHttpRequest();
     $service = $this->get('buggl_photo.uploader_service')->createUploadPath()->setOptions(array('isAjax' => $isAjax, 'file' => $isAjax ? $request->get('file') : $_FILES['file']))->setPaths();
     $photoUploader = $service->upload()->getPhotoUploader();
     $status = $photoUploader->getStatus();
     $success = false;
     if (!$status['error']) {
         $photo = new CategoryPhoto();
         $photo->setFilename($photoUploader->getFilename());
         $photo->setDateAdded(new \DateTime(date('Y-m-d H:i:s', time())));
         $photo->setTags(json_encode(array()));
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($photo);
         $em->flush();
         $sucess = true;
     }
     $result = array('e_id' => $request->get('e_id'), 'success' => $success);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 /**
  * saves the photo info upon uploading to servcer
  * @param string $filename []
  * @param string $path     []
  *
  * @return Buggl\MainBundle\Entity\CategoryPhoto
  */
 public function saveCategoryPhoto($filename, $path)
 {
     $object = new CategoryPhoto();
     $object->setFilename($filename);
     $object->setTags(json_encode(array()));
     $object->setDateAdded(new \DateTime(date('Y-m-d H:i:s', time())));
     $object->setPath($path);
     $this->entityManager->persist($object);
     $this->entityManager->flush();
     return $object;
 }
 /**
  * Get imageWebPath
  *
  * @return \Buggl\MainBundle\Entity\Category
  */
 public function getImageWebPath()
 {
     return 'uploads/images/' . $this->categoryToCountryPhoto->getFilename();
 }