zoukankan      html  css  js  c++  java
  • 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.
    服务器路径换成绝对路径

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

  • 相关阅读:
    bzoj1007: [HNOI2008]水平可见直线(单调栈)
    1264: [AHOI2006]基因匹配Match(动态规划神题)
    bzoj1433: [ZJOI2009]假期的宿舍(最大二分图匹配)
    bzoj3931: [CQOI2015]网络吞吐量(spfa+网络流)
    [ZJOI2007]矩阵游戏
    [HAOI2007]覆盖问题
    [ZJOI2008]树的统计
    [ZJOI2010]数字计数
    [HAOI2006]旅行
    [HAOI2006]数字序列
  • 原文地址:https://www.cnblogs.com/zhangxiangdong/p/9140088.html
Copyright © 2011-2022 走看看