public function del()
 {
     $msg = '';
     $rs = false;
     try {
         if (!IS_AJAX) {
             throw new \Exception(L('_ERR_FORMART_VISIT_', array('visit' => 'ajax')), 100);
         }
         $cid = I('get.cid');
         if (!$cid) {
             throw new \Exception(L('_ERR_FORMART_PARAMS_NUM', array('param' => 'cid')));
         }
         $rs = $this->objServ->delRow($cid);
     } catch (\Exception $e) {
         $msg = $e->getMessage();
         if ($e->getCode() == 100) {
             return $this->show($msg);
         }
     }
     return get_api_result('Home', $rs, $msg);
 }
 public function upload()
 {
     try {
         $config = C('upload');
         $upload = new \Think\Upload($config);
         $info = $upload->upload();
         $errmsg = null;
         if (!$info) {
             $errmsg = $upload->getError();
             throw new \Exception($this->errcode . ':' . $errmsg);
             // return get_api_result('component', array(), $this->errcode.':'.$errmsg);
         }
         $fileinfo = array();
         $attData = array();
         // 存储文件信息
         foreach ($info as $val) {
             $fileinfo['atname'] = $val['savename'];
             $fileinfo['atpath'] = $val['savepath'];
             $fileinfo['atmine'] = $val['type'];
             $fileinfo['atext'] = $val['ext'];
             $fileinfo['created'] = time();
             if (in_array($val['ext'], $this->imgExts)) {
                 $fileinfo['attype'] = 1;
             }
             $attData[] = $fileinfo;
         }
         $attModel = D('Attachment');
         $rs = $attModel->data($attData)->addAll($attData);
         if (!$rs) {
             throw new \Exception(L('_ERR_UPLOAD_'));
         }
         $attInfo = array();
         $attInfo['aid'] = $rs;
         $attInfo['att_url'] = set_attr_url($rs);
         return get_api_result('component', $attInfo);
     } catch (\Exception $e) {
         $errInfo = $e->getMessage();
         return get_api_result('component', array(), $errInfo);
     }
 }