tp5.0.24未定义的数组

浏览:55 发布日期:2019/08/13 分类:求助交流 关键字: 未定义的数组
本地PHPstudy,php5.6

报错在第16行

C端    public function add()
    {
      if(request()->isPost()){
          $data=[
              'title'=>input('title'),
              'author'=>input('author'),
              'desc'=>input('desc'),
              'keyword'=>input('keyword'),
              'cateid'=>input('cateid'),
              'content'=>input('content'),
              'time'=>time(),
              ];
          if(input('state'=='on')){
              $data['state']=1;
          }
          if($_FILES['pic']['tmp_name']){
            $file = request()->file('pic');
            $info = $file ->move(ROOT_PATH . 'public' . DS . '/static/admin/uploads/');
            $data['pic']='/uploads/'.$info->getSaveName();
          }
          $validate = \think\Loader::validate('Article');
            if(!$validate->scene('add')->check($data)){
             $this->error($validate->getError());
             }
         if(Db('article')->insert($data)){
             return $this->success('添加文章成功','lst');
         }else{
             return $this->error('添加文章失败!');
         }
         }
        $cateres= db('cate')->select();
        $this->assign('cateres',$cateres);
        return $this-> fetch();
    }
V端<!DOCTYPE html>
<html><head>
        <meta charset="utf-8">
    <title>122324</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__PUBLIC__/style/bootstrap.css" rel="stylesheet">
    <link href="__PUBLIC__/style/font-awesome.css" rel="stylesheet">
    <link href="__PUBLIC__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__PUBLIC__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/style/demo.css" rel="stylesheet">
    <link href="__PUBLIC__/style/typicons.css" rel="stylesheet">
    <link href="__PUBLIC__/style/animate.css" rel="stylesheet">
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.parse.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.parse.min.js"></script>


    
</head>
<body>
    <!-- 头部 -->
    <!-- 头部 -->
    {include file="common/top"/}
    <!-- /头部 -->

    <div class="main-container container-fluid">
        <div class="page-container">
            <!-- Page Sidebar -->
            {include file="common/left"/}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="#">系统</a>
                    </li>
                                        <li>
                        <a href="{:url('article/lst')}">文章管理</a>
                    </li>
                                        <li class="active">添加文章</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header bordered-bottom bordered-blue">
                <span class="widget-caption">新增文章</span>
            </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form" action="" method="post">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label no-padding-right">文章标题</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="title" placeholder="" name="title"  type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>

                        <div class="form-group">
                            <label for="groupid" class="col-sm-2 control-label no-padding-right">文章作者</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="author" placeholder="" name="author"  type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>

                        </div>

                        <div class="form-group">
                            <label for="groupid" class="col-sm-2 control-label no-padding-right">文章简介</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="desc" placeholder="" name="desc"  type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>

                        </div>
                        <div class="form-group">
                            <label for="groupid" class="col-sm-2 control-label no-padding-right">文章关键词</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="keywords" placeholder="" name="keywords"  type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>

                        </div>
                        <div class="form-group">
                            <label for="groupid" class="col-sm-2 control-label no-padding-right">文章缩略图</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="pic" placeholder="" name="pic"  type="file">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>

                        </div>


                        <div class="form-group">
                            <label for="group_id" class="col-sm-2 control-label no-padding-right">所属栏目</label>
                            <div class="col-sm-6">
                                <select id="cateid" placeholder="" name="cateid" style="width: 50%;">
                                    <option >所属栏目</option>
                                    {volist name="cateres" id="vo"}
                                    <option  value="{$vo.id}">{$vo.catename}</option>
                                    {/volist}

                                </select>
                            </div>
                        </div>
                            <div class="form-group"></div>
                            <div class="form-group">
                            <label for="group_id" class="col-sm-2 control-label no-padding-right">是否推荐</label>

                                <label>
                                    <input class="checkbox-slider colored-blue" name="state" checked="checked" type="checkbox">
                                    <span class="text"></span>
                                </label>
                            </div>
                            <div class="form-group">
                                <label for="groupide" class="col-sm-2 control-label no-padding-right">文章正文</label>
                                <div class="col-sm-6">
                                    <textarea  id="container"  name="content"  type="text"></textarea>
                                </div>
                                <p class="help-block col-sm-4 red">* 必填</p>
                            </div>
                            <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">保存信息</button>
                            </div>
                        </div>
                     </form>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
        </div>    
    </div>

        <!--Basic Scripts-->
    <script src="__PUBLIC__/style/jquery_002.js"></script>
    <script src="__PUBLIC__/style/bootstrap.js"></script>
    <script src="__PUBLIC__/style/jquery.js"></script>
    <!--Beyond Scripts-->
    <script src="__PUBLIC__/style/beyond.js"></script>
    <script type="text/javascript">
        UE.getEditor('container');
    </script>
</body></html>
运行时出错,报:[8] ErrorException in Article.php line 28
未定义数组索引: pic

打印$POST也是这个错误 ,打印$data
最佳答案
评论( 相关
后面还有条评论,点击查看>>