Ejemplo n.º 1
0
 public function indexAction()
 {
     // no output before this declaration
     $form = new Album_Form_Upload();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             if (method_exists($form->getElement('file'), 'isUploadify')) {
                 if (!$form->getElement('file')->isUploadify()) {
                     // Uploadify was not used even it was meant to be, f.e. javascript was disabled
                     $form->getElement('file')->addFilter('rename', $form->getElement('file')->getRandomFileName())->receive();
                 }
                 /**
                  * Here you can rename/copy/process files
                  * ideal situation is, that you upload file to temporary directory,
                  * than processes it, copy it to directory, where you want to store it
                  * and maybe rename to original filename or something else
                  */
                 // filename on HDD after upload was processed
                 //echo $form->getElement('file')->getFileName() . '<br/>';
                 // if was used rename filter in library/My/Form/Element/File.php, this will return original file name
                 //echo $form->getElement('file')->getOriginalFileName() . '<br/>';
             } else {
                 /**
                  * Uplodify was not used, Zend_Form_Element_File was used instead.
                  * You dont need this code when you decide to use My_Form_Element_File.
                  * If you use this code, replace "random" with your custom random file name, to prevent file collision.
                  */
                 $form->getElement('file')->addFilter('rename', 'random')->receive();
             }
             $this->_redirect('/uploaded');
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 2
0
 public function albumUploadPhotoAction()
 {
     $this->_helper->layout()->disableLayout();
     $albumId = $this->_getParam('album_id');
     // For uploade photo on edit time of Album
     $this->view->albumId = $albumId;
     // For uploade photo on edit time of Album
     $review_edit = $this->_getParam('review_edit');
     // For uploade photo on Album create time
     $this->view->review_edit = $review_edit;
     // For uploade photo on Album create time
     $objModelAlbum = new Album_Model_Album();
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     /*---------------------- GET USED PHOTO SIZE OF USER --------------------------*/
     $arrAlbumCapacity = $objModelAlbum->albumCapacity($userId);
     $this->view->capacityImage = $arrAlbumCapacity[0];
     $this->view->capacityPercent = $arrAlbumCapacity[1];
     $whereAlbum = "status=1 AND user_id='{$userId}'";
     $orderAlbum = "addedon DESC";
     $arrAlbum = $objModelAlbum->fetchAll($whereAlbum, $orderAlbum);
     $this->view->arrAlbum = $arrAlbum;
     /*---------------------------------------------------------------------*/
     // no output before this declaration
     $form = new Album_Form_Upload();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             if (method_exists($form->getElement('file'), 'isUploadify')) {
                 if (!$form->getElement('file')->isUploadify()) {
                     // Uploadify was not used even it was meant to be, f.e. javascript was disabled
                     $form->getElement('file')->addFilter('rename', $form->getElement('file')->getRandomFileName())->receive();
                 }
                 /**
                  * Here you can rename/copy/process files
                  * ideal situation is, that you upload file to temporary directory,
                  * than processes it, copy it to directory, where you want to store it
                  * and maybe rename to original filename or something else
                  */
                 // filename on HDD after upload was processed
                 //echo $form->getElement('file')->getFileName() . '<br/>';
                 // if was used rename filter in library/My/Form/Element/File.php, this will return original file name
                 //echo $form->getElement('file')->getOriginalFileName() . '<br/>';
             } else {
                 /**
                  * Uplodify was not used, Zend_Form_Element_File was used instead.
                  * You dont need this code when you decide to use My_Form_Element_File.
                  * If you use this code, replace "random" with your custom random file name, to prevent file collision.
                  */
                 $form->getElement('file')->addFilter('rename', 'random')->receive();
             }
             $this->_redirect('/test-upload');
         }
     }
     $this->view->form = $form;
 }