Ejemplo n.º 1
0
 /**
  *动作: 新增文章
  **/
 public function store()
 {
     if ($_FILES['article_photo']['name']) {
         $res = $this->upload($_FILES['article_photo']);
     }
     $article = new Article();
     $data = $_POST;
     $user = session('admin.admin');
     $data['author'] = $user['username'];
     $data['article_photo'] = $res ? __ROOT__ . '/uploads/' . $res : __ROOT__ . '/Public/img/111.jpg';
     $data['created_at'] = date("Y-m-d H:i:s", time());
     $data['updated_at'] = date("Y-m-d H:i:s", time());
     if ($article->add($data)) {
         session('admin.success_msg', '添加成功');
         $this->redirect('Article/index', '', 0, '');
         //$this->success('发表成功');
         // $this->ajaxReturn(array('ret'=>0));
     }
     $this->ajaxReturn(array('ret' => 1));
 }