Ejemplo n.º 1
0
 public function profileActAction()
 {
     $m['realname'] = $this->getPost('realname');
     $m['provinceID'] = $this->getPost('areaProvince');
     $m['cityID'] = $this->getPost('areaCity');
     $m['regionID'] = $this->getPost('areaRegion');
     $m['province'] = $this->load('Province')->getProvinceNameByID($m['provinceID']);
     $m['city'] = $this->load('City')->getCityNameByID($m['cityID']);
     if ($m['regionID']) {
         $m['region'] = $this->load('Region')->getRegionNameByID($m['regionID']);
     }
     $code = $this->m_user->UpdateByID($m, USER_ID);
     // Upload avatar if selected
     if ($_FILES['avatar']['name']) {
         Helper::import('File');
         Yaf_Loader::import('L_Upload.class.php');
         $fileName = CUR_TIMESTAMP;
         $up = new L_Upload($_FILES['avatar'], UPLOAD_PATH . '/');
         $result = $up->upload($fileName);
         if ($result == 1) {
             $m['avatar'] = $fileName . '.' . $up->extension;
             $this->m_user->UpdateByID($m, USER_ID);
         } else {
             jsAlert($result);
         }
     }
     if (FALSE === $code && $result != 1) {
         jsAlert('编辑个人信息失败, 请重试');
     }
     $this->redirect('/user/profile/edit');
 }
Ejemplo n.º 2
0
 public function handleUploadImgAction()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     Yaf_loader::import(LIB_PATH . '/L_Upload.class.php');
     $obj = new L_Upload();
     //实例化上传类
     $obj->maxSize = 1000000;
     //图片最大上传大小
     $obj->savePath = getcwd() . '/Uploads/new/';
     //图片保存路径
     $obj->saveRule = 'uniqid';
     //保存文件名
     $obj->uploadReplace = true;
     //是否覆盖同名文件 是
     $obj->allowExts = array(0 => 'jpg', 1 => 'jpeg', 2 => 'gif', 3 => 'png');
     //允许上传文件后缀名
     $obj->thumb = false;
     //生成缩略图
     $obj->autoSub = true;
     //使用子目录保存上传文件
     $obj->subType = 'date';
     //使用日期为子目录名称
     $obj->dateFormat = 'Y_m_d';
     //使用年-月形式
     if (!$obj->upload()) {
         echo json_encode(array('status' => 0, 'msg' => $obj->getErrorMsg()));
         die;
     } else {
         $info = $obj->getUploadFileInfo();
         $pic = explode('/', $info[0]['savename']);
         $return = array('status' => 1, 'path' => '/Uploads/new/' . $pic[0] . '/' . $pic[1]);
         //压缩图片
         image_png_size_add(getcwd() . '/Uploads/new/' . $pic[0] . '/' . $pic[1], getcwd() . '/Uploads/new/' . $pic[0] . '/' . $pic[1]);
         echo json_encode($return);
         die;
     }
 }