Ejemplo n.º 1
0
 /**
  * 文件上传入口
  */
 public function upload()
 {
     // TODO 目前只支持单一文件异步上传
     $return = array('status' => 0, 'info' => '', 'data' => '');
     /* 调用文件上传组件上传文件 */
     $info = $this->model->upload($_FILES);
     /* 记录附件信息 */
     if ($info) {
         $return['status'] = 1;
         $return['data'] = array('path' => $info['path'], 'key' => token_builder($info['id']));
         $return['info'] = $info['name'] . ' 上传成功!';
     } else {
         $return['info'] = $this->model->getError();
     }
     /* 返回JSON数据 */
     $this->ajaxReturn($return);
 }
Ejemplo n.º 2
0
 /**
  * 表单编辑数据响应
  * 
  * AJAX入口
  * @param array $json 引用型接收
  */
 protected function ajax_edit(&$json)
 {
     $id = act_decrypt($en = I('pk'));
     $GLOBALS['ajaxQuery'] = 'edit';
     $GLOBALS['ajaxPk'] = $id;
     if ($id) {
         $json['val'] = $this->edit($id);
     }
     if ($json['status'] = !!$json['val']) {
         $json['token'] = token_builder($en);
     }
     $json['info'] = $json['status'] ? '请求成功!' : ($this->getError() ?: '要请求的数据不可访问!');
     if ($json['status'] && $this->pageOptions['editFields']) {
         $json['columns'] = $this->packColumns();
     }
 }