public function deleteItem($arrParams = null, $Option = null)
 {
     if ($Option['task'] == 'admin-delete') {
         //Lay thong tin user can xoa
         $row = $this->getItem($arrParams, array('task' => 'delete'));
         //Xo� hinh avatar cua user
         $upload_dir = FILES_PATH . '/photo/album-dtl';
         $upload = new Zendda_File_Upload();
         $upload->removeFile($upload_dir . '/' . $row['image_actual']);
         $upload->removeFile($upload_dir . '/thumbnails/' . $row['image_thumb']);
         $where = 'id = ' . $arrParams['id'];
         $result = $this->delete($where);
     }
     if ($Option['task'] == 'admin-multi-delete') {
         if (count($arrParams['cid']) > 0) {
             foreach ($arrParams['cid'] as $key) {
                 $arrParams['id'] = $key;
                 //Lay thong tin user can xoa
                 $row = $this->getItem($arrParams, array('task' => 'delete'));
                 //Xo� hinh avatar cua user
                 $upload_dir = FILES_PATH . '/photo/album-dtl';
                 $upload = new Zendda_File_Upload();
                 $upload->removeFile($upload_dir . '/' . $row['image_actual']);
                 $upload->removeFile($upload_dir . '/thumbnails/' . $row['image_thumb']);
             }
             //xoa thong tin cac user khoi database
             $cid = implode(',', $arrParams['cid']);
             $where = 'id IN (' . $cid . ')';
             $result = $this->delete($where);
         }
     }
     return $result;
 }
 public function uploadImageAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     if (!empty($_FILES)) {
         $tempFile = $_FILES['Filedata']['tmp_name'];
         //$targetPath = FILES_PATH . '/photo/album-dtl';
         // Validate the file type
         $fileTypes = array('jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG');
         // File extensions
         $fileParts = pathinfo($_FILES['Filedata']['name']);
         //$newName = "album_" . time ();
         //$targetFile = rtrim($targetPath,'/') . '/'.$newName .'.'. $fileParts['extension'];
         if (in_array($fileParts['extension'], $fileTypes)) {
             /*move_uploaded_file($tempFile,$targetFile);
             		echo $newName .'.'. $fileParts['extension'];*/
             $upload_dir = FILES_PATH . '/photo';
             $upload = new Zendda_File_Upload();
             $fileName = $_FILES['Filedata']['name'];
             if (!empty($fileName)) {
                 $fileName = $upload->upload($fileName, $upload_dir . '/album-dtl', array('task' => 'rename'), 'album_');
                 $thumb = Zendda_File_Images::create($upload_dir . '/album-dtl/' . $fileName);
                 $thumb->resize(200, 200)->save($upload_dir . '/album-dtl/thumbnails/' . $fileName);
             }
             echo $fileName;
         } else {
             echo 'Invalid file type.';
         }
     }
 }
 public function uploadFile($param)
 {
     if (!empty($param)) {
         $upload_dir = FILES_PATH . '/group/' . $param;
         $upload = new Zendda_File_Upload();
         $fileInfo = $upload->getFileInfo($param);
         $fileName = $fileInfo[$param]['name'];
         if (!empty($fileName)) {
             $fileName = $upload->upload($fileName, $upload_dir . '/orignal', array('task' => 'rename'), 'group_' . $param . '_');
             $thumb = Zendda_File_Images::create($upload_dir . '/orignal/' . $fileName);
             $thumb->resize(100, 100)->save($upload_dir . '/img100x100/' . $fileName);
             $thumb = Zendda_File_Images::create($upload_dir . '/orignal/' . $fileName);
             $thumb->resize(450, 450)->save($upload_dir . '/img450x450/' . $fileName);
             if ($this->_arrData['action'] == 'edit') {
                 $upload->removeFile($upload_dir . '/orignal/' . $this->_arrData['current_group_' . $param]);
                 $upload->removeFile($upload_dir . '/img100x100/' . $this->_arrData['current_group_' . $param]);
                 $upload->removeFile($upload_dir . '/img450x450/' . $this->_arrData['current_group_' . $param]);
             }
         } else {
             if ($this->_arrData['action'] == 'edit') {
                 $fileName = $this->_arrData['current_group_' . $param];
             }
         }
     }
     return $fileName;
 }
 public function deleteItem($arrParams = null, $Option = null)
 {
     if ($Option['task'] == 'admin-delete') {
         //Lay thong tin can xoa hinh
         $row = $this->getItem($arrParams, array('task' => 'delete-item'));
         $upload_dir = FILES_PATH . '/group';
         $upload = new Zendda_File_Upload();
         //Xoa hinh avatar cua group
         $upload->removeFile($upload_dir . '/avatar/orignal/' . $row['avatar']);
         $upload->removeFile($upload_dir . '/avatar/img100x100/' . $row['avatar']);
         $upload->removeFile($upload_dir . '/avatar/img450x450/' . $row['avatar']);
         //Xoa hinh ranking cua group
         $upload->removeFile($upload_dir . '/ranking/orignal/' . $row['ranking']);
         $upload->removeFile($upload_dir . '/ranking/img100x100/' . $row['ranking']);
         $upload->removeFile($upload_dir . '/ranking/img450x450/' . $row['ranking']);
         //Xoa group khoi database
         $where = 'id = ' . $arrParams['id'];
         $this->delete($where);
     }
     if ($Option['task'] == 'admin-multi-delete') {
         if (count($arrParams['cid']) > 0) {
             foreach ($arrParams['cid'] as $key) {
                 $arrParams['id'] = $key;
                 $row = $this->getItem($arrParams, array('task' => 'delete-item'));
                 $upload_dir = FILES_PATH . '/group';
                 $upload = new Zendda_File_Upload();
                 //Xoa hinh avatar cua group
                 $upload->removeFile($upload_dir . '/avatar/orignal/' . $row['avatar']);
                 $upload->removeFile($upload_dir . '/avatar/img100x100/' . $row['avatar']);
                 $upload->removeFile($upload_dir . '/avatar/img450x450/' . $row['avatar']);
                 //Xoa hinh ranking cua group
                 $upload->removeFile($upload_dir . '/ranking/orignal/' . $row['ranking']);
                 $upload->removeFile($upload_dir . '/ranking/img100x100/' . $row['ranking']);
                 $upload->removeFile($upload_dir . '/ranking/img450x450/' . $row['ranking']);
             }
             $cid = implode(',', $arrParams['cid']);
             $where = 'id IN (' . $cid . ')';
             $this->delete($where);
         }
     }
 }
 public function uploadFile()
 {
     $upload_dir = FILES_PATH . '/news';
     $upload = new Zendda_File_Upload();
     $fileInfo = $upload->getFileInfo('picture');
     $fileName = $fileInfo['picture']['name'];
     if (!empty($fileName)) {
         $fileName = $upload->upload($fileName, $upload_dir . '/img_big', array('task' => 'rename'), 'news_');
         $thumb = Zendda_File_Images::create($upload_dir . '/img_big/' . $fileName);
         $thumb->resize(200, 200)->save($upload_dir . '/img_small/' . $fileName);
         if ($this->_arrData['action'] == 'edit') {
             $upload->removeFile($upload_dir . '/img_big/' . $this->_arrData['current_item_picture']);
             $upload->removeFile($upload_dir . '/img_small/' . $this->_arrData['current_item_picture']);
         }
     } else {
         if ($this->_arrData['action'] == 'edit') {
             $fileName = $this->_arrData['current_item_picture'];
         }
     }
     return $fileName;
 }
Example #6
0
 public function deleteItem($arrParams = null, $Option = null)
 {
     if ($Option['task'] == 'admin-delete') {
         //Lay thong tin user can xoa
         $row = $this->getItem($arrParams, array('task' => 'delete'));
         //Xo� hinh avatar cua user
         $upload_dir = FILES_PATH . '/users';
         $upload = new Zendda_File_Upload();
         $upload->removeFile($upload_dir . '/orignal/' . $row['user_avatar']);
         $upload->removeFile($upload_dir . '/img100x100/' . $row['user_avatar']);
         $upload->removeFile($upload_dir . '/img450x450/' . $row['user_avatar']);
         //xo� thong tin user khoi database
         $where = 'id = ' . $arrParams['id'];
         $this->delete($where);
     }
     if ($Option['task'] == 'admin-multi-delete') {
         if (count($arrParams['cid']) > 0) {
             foreach ($arrParams['cid'] as $key) {
                 $arrParams['id'] = $key;
                 //Lay thong tin user can xoa
                 $row = $this->getItem($arrParams, array('task' => 'delete'));
                 //Xo� hinh avatar cua user
                 $upload_dir = FILES_PATH . '/users';
                 $upload = new Zendda_File_Upload();
                 $upload->removeFile($upload_dir . '/orignal/' . $row['user_avatar']);
                 $upload->removeFile($upload_dir . '/img100x100/' . $row['user_avatar']);
                 $upload->removeFile($upload_dir . '/img450x450/' . $row['user_avatar']);
             }
             //xoa thong tin cac user khoi database
             echo '<br>' . ($cid = implode(',', $arrParams['cid']));
             $where = 'id IN (' . $cid . ')';
             $this->delete($where);
         }
     }
 }