【问题标题】:CodeIgniter not uploading any image when on live serverCodeIgniter 在实时服务器上不上传任何图像
【发布时间】:2017-03-27 08:07:56
【问题描述】:

我正在尝试在实时服务器上上传 CodeIgniter 中的文件。它在本地主机上运行良好,但是当我尝试在实时服务器上上传它时,上传库无法正常工作,你能告诉我我做错了什么吗?是否需要更改实时服务器的 php.ini 中的某些内容?

这是我的代码:

  public function do_upload()
  { 
      $config = [
                'upload_path' =>    './uploads',
                'allowed_types' =>    'jpg|gif|png|jpeg',
                'max_size'            => 1100000000,
                'max_width'            => 102400000,
                'max_height'           => 76800000,
                 ]; 
                 // print_r($config);
                 // exit();
            $upload=     $this->load->library('upload');
         $this->load->library('upload', $config);
         $this->upload->initialize($config); 
         // var_dump($config);
         var_dump($upload);
         // exit();
       if(!$this->upload->do_upload('imagefile')) 
        {
          $upload_error = $this->upload->display_errors();
          $this->load->view('site/timeline/timeline_profile',compact('upload_error'));
        } 
        else
        {
          $post = $this->input->post();
          unset($post['submit']);
          $upload_data = $this->upload->data(); 
          $file_name=$_FILES['imagefile'];
          $this->load->model('Timeline_model');
          $this->Timeline_model->upload_model($post,$file_name);
          echo $image_path= base_url("uploads/".$upload_data['raw_name'].$upload_data['file_ext']);
        }
  }

在 var dump 上它显示的值为 null。

【问题讨论】:

  • 从逻辑上讲,它应该不会显示任何内容,因为您正在转储 $upload,而它从库加载中什么也得不到。转储 $this->upload->data();在你的 else 语句或 $upload_data 变量中
  • 也尝试这样做,但值仍然为空 @MalikMudassar

标签: php codeigniter


【解决方案1】:

请完全按照File Uploading Class 中的代码进行操作,并确保您具有在服务器中上传文件夹的写入权限。

【讨论】:

  • 检查了我可以访问路径但上传库仍然无法正常工作
  • 检查文件夹权限
猜你喜欢
  • 2016-02-07
  • 2017-06-07
  • 2019-02-20
  • 1970-01-01
  • 2021-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-17
相关资源
最近更新 更多