首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >上载数据库中的图像和图像名称时出错,codeigniter

上载数据库中的图像和图像名称时出错,codeigniter
EN

Stack Overflow用户
提问于 2019-02-22 04:41:47
回答 2查看 60关注 0票数 0

在Codeigniter中上传图像时出错。文件名noimage保存在数据库中。

//上传图片控制器

代码语言:javascript
复制
      $config['upload_path'] = './assets/Images/profilepictures';
      $config['allowed_types'] = 'gif|jpg|png|jpeg';
      $config['max_size'] = '2048';
      $config['max_width'] = '2000';
      $config['max_height'] = '2000';

      $this->load->library('upload', $config);

      if(!$this->upload->do_upload()){
          $errors = array('error' => $this->upload->display_errors());
          $post_image = 'noimage.jpg';
      } else {
          $data = array('upload_data' => $this->upload->data());
          $post_image = $_FILES['userfile']['name'];
      }

      $this->m_user->profilepicture($post_image);
      if($data['user']->profile_pic==null)
      {
            redirect(base_url().'user/profilepicture/');

      }

模型

代码语言:javascript
复制
    public function profilepicture($post_image){
$userID = $this->session->userdata("user_id");
            $data = array(
            'profile_pic' => $post_image,
            );
      $this->db->where('user_id', $userID);
      $this->db->update('users', $data);
    }
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54815880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档