Пример #1
0
 public function addAction()
 {
     $form = new ImageForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $image = new Image();
         $form->setInputFilter($image->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $image->exchangeArray($form->getData());
             $this->getImageTable()->saveImage($image);
             // Redirect to list of albums
             return $this->redirect()->toRoute('image');
         }
     }
     return array('form' => $form);
 }
Пример #2
0
 public function addAction()
 {
     $form = new ImageForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $image = new Image();
         $form->setInputFilter($image->getInputFilter());
         $nonFile = $request->getPost()->toArray();
         $File = $this->params()->fromFiles('lien');
         $names = $File['name'];
         echo $names;
         $form->setData($request->getPost());
         $data = array_merge($nonFile, array('fileupload' => $File['name']));
         if ($form->isValid()) {
             $image->exchangeArray($form->getData());
             $this->getImageTable()->saveImage($image);
             // Redirect to list of images
             return $this->redirect()->toRoute('image');
         }
     }
     return array('form' => $form);
 }
Пример #3
0
 public function addAction()
 {
     $logged = $this->getConnection();
     $form = new ImageForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $image = new Image();
         $form->setInputFilter($image->getInputFilter());
         $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form->setData($post);
         if ($form->isValid()) {
             $data = $form->getData();
             //On créer la procédure pour renomer l'image
             $filter = new \Zend\Filter\File\Rename(array("source" => getcwd() . '/public/img/BanqueImage/' . $data['lien']['name'], "target" => getcwd() . '/public/img/BanqueImage', "randomize" => true));
             $adapter = new \Zend\File\Transfer\Adapter\Http();
             $adapter->setDestination(getcwd() . '/public/img/BanqueImage/');
             if ($adapter->receive($data['lien']['name'])) {
                 //On renomme l'image pour éiter les doublons
                 $imageName = basename($filter->filter(getcwd() . '/public/img/BanqueImage/' . $data['lien']['name']));
                 $saveImage = array('idMembre' => $logged, 'lien' => $imageName);
                 $image->exchangeArray($saveImage);
                 $this->getImageTable()->saveImage($image);
             }
             // Redirect to list of images
             return $this->redirect()->toRoute('image', array('action' => 'membre', 'id' => $logged));
         }
     }
     return array('form' => $form);
 }