public function addAction()
 {
     //		$ddl_video_category = Zend_Registry::get('ddl_video_category');
     //		$this->view->ddl_video_category = $ddl_video_category;
     $faqs = new Application_Model_Faqs();
     $ddl_video_category = $faqs->fetchCategoryItems(2);
     $this->view->ddl_video_category = $ddl_video_category;
     if ($this->request->isPost()) {
         $videos = new Application_Model_Videos();
         $userid = $this->user->getId();
         $actiontype = $this->request->getParam('actiontype');
         if ($actiontype == 'upload') {
             $target_path = '../public/videos/';
             $id = $this->user->getId();
             $filename = $this->request->getParam('category') . '-' . $_FILES['video_name']['name'];
             $target_path = $target_path . basename($filename);
             $videosArray = array();
             $videosArray = array("category" => $this->request->getParam('category'), "video_title" => $this->request->getParam('video_title'), "video_description" => $this->request->getParam('video_description'), "video_name" => $filename, "modified_by" => $userid);
             $error = "";
             if ($_FILES['video_name']['type'] == 'video/mp4') {
                 if (move_uploaded_file($_FILES['video_name']['tmp_name'], $target_path)) {
                     if ($videos->add($userid, $videosArray)) {
                         $message = 'Video Added.';
                     } else {
                         $error = 'Video error: ' . $videos->getError();
                     }
                 } else {
                     $error = 'There was an error uploading the file, please try again!';
                 }
             } else {
                 $error = 'Video format not supported..!';
             }
         }
         if (empty($error)) {
             return $this->_redirect('videos/index');
         } else {
             $this->view->error = $error;
             $this->view->video_title = $this->request->getParam('video_title');
             $this->view->video_description = $this->request->getParam('video_description');
             $this->view->category = $this->request->getParam('category');
         }
     }
 }
 public function fileuploadAction()
 {
     if ($this->getRequest()->isPost()) {
         $userid = $this->user->getId();
         $upload = new Zend_File_Transfer_Adapter_Http();
         $videos = new Application_Model_Videos();
         $docs = array("doc", "pdf", "txt", "img", "xls", "xlsx");
         $category = $this->request->getParam('category');
         if (in_array($category, $docs)) {
             $upload->setDestination($_SERVER['DOCUMENT_ROOT'] . "/data");
             $fname = $this->request->getParam('ftitle');
             $fextension = "";
             $files = $upload->getFileInfo();
             foreach ($files as $fieldname => $fileinfo) {
                 if ($upload->isUploaded($fileinfo['name']) && $upload->isValid($fileinfo['name'])) {
                     $upload->receive($fileinfo['name']);
                     $fname = $fileinfo['name'];
                     $fextension = pathinfo($fname, PATHINFO_EXTENSION);
                 }
             }
             $videosArray = array("category" => $this->request->getParam('category'), "title" => $this->request->getParam('ftitle'), "description" => $this->request->getParam('fdescription'), "name" => $fname, "mark" => $this->request->getParam('fmark'));
             if ($upload->receive()) {
                 $videos->insertData($userid, $videosArray);
                 echo "The file has been uploaded!<>" . $fname . "===" . $fextension;
             }
         } else {
             $upload->setDestination($_SERVER['DOCUMENT_ROOT'] . "/videos");
             $fname = $this->request->getParam('ftitle');
             $fextension = "";
             $files = $upload->getFileInfo();
             foreach ($files as $fieldname => $fileinfo) {
                 if ($upload->isUploaded($fileinfo['name']) && $upload->isValid($fileinfo['name'])) {
                     $upload->receive($fileinfo['name']);
                     $fname = $fileinfo['name'];
                     $fextension = pathinfo($fname, PATHINFO_EXTENSION);
                 }
             }
             $videosArray = array("category" => $this->request->getParam('category'), "video_title" => $this->request->getParam('ftitle'), "video_description" => $this->request->getParam('fdescription'), "video_name" => $fname, "modified_by" => $userid);
             if ($upload->receive()) {
                 $videos->add($userid, $videosArray);
                 echo "The file has been uploaded!<>" . $fname . "===" . $fextension;
             }
         }
         //end of else
     }
     /*  
      * how to reaname uploaded file name
      * $rename = new Zend_Filter_File_Rename(array(
             'target'    =>$upf_name,
             'overwrite' => true
           ));
          $upload->addFilter($rename);*/
 }