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.
    服务器路径换成绝对路径

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

  • 相关阅读:
    tomcat 7服务器跨域问题解决
    logstash 改变行分割符
    logstash 编码转换默认UTF8
    GIT常用命令
    GIT常用命令
    GIT常用命令
    介绍开发流程以及相关技术
    介绍开发流程以及相关技术
    介绍开发流程以及相关技术
    介绍开发流程以及相关技术
  • 原文地址:https://www.cnblogs.com/zhangxiangdong/p/9140088.html
Copyright © 2011-2022 走看看