ci做的一个多图上传

function upfile()
    {
        foreach($_FILES as $k=>$v)
        {
            if($_FILES[$k]['name'] == '')
            {
                unset($_FILES[$k]);
            }
        }
        if(count($_FILES)>0)
        {
            $uArr = $_SESSION['applyuser'];
            $upload_config = array(
                'upload_path' => 'uploads/file/' . date ( 'Ym' ) . '/' . date ( 'd' ).'/',
                'allowed_types' => 'jpg|jpeg|png|bmp|gif',
                'max_size' => '1024',
                'max_width' => '1024',
                'max_height' => '1024',
                'file_name' => time ().rand ( 100000, 999999 ),
              );
            $this->load->library('upload');
            mkdirs ( FCPATH.$upload_config ['upload_path'] );
            $this->upload->initialize($upload_config);
            $imgArr = array();
            foreach ($_FILES as $key => $value)
            {
                if(!empty($_FILES[$key]))
                {
                      if ($this->upload->do_upload($key))
                      {
                        $pathArr = $this->upload->data();
                        $imgArr[] = $_SERVER['HTTP_HOST'].'/'.$upload_config ['upload_path'].$pathArr['file_name'];
                      }
                      else
                      {
                        //上传失败
                        $rtn = $this->upload->display_errors();
                      }
                }
                
            }
            
            $imgArr = json_encode($imgArr);
            $id = $uArr['id'];
            $data['imgpath'] = $imgArr;
            $data['beforehand1'] = 1;
            $this->db->where('userid', $id);
            $this->db->update('mba_apply_user_apply', $data);
            redirect('apply/user/index');
            //ajaxReturn($rtn, $info = '什么都没传', $status = 1, $type = 'JSON',$ser='');
        }
    }

报错
error:The upload path does not appear to be valid.
服务器路径换成绝对路径

我的表单是这样的    此处略去。。。。。。

 

转载于:https://www.cnblogs.com/zhangxiangdong/p/9140088.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值