CodeIgniter在实时服务器上不上传任何图像

时间:2017-03-27 08:07:57

标签: php codeigniter

我正在尝试在实时服务器上上传CodeIgniter中的文件。它在localhost上工作得很好,但是当我尝试在实时服务器上传它时,上传库无法正常工作,请你告诉我我做错了什么?我需要在live服务器的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转储它显示的值为null。

1 个答案:

答案 0 :(得分:0)

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