FIle upload from a rest client to a rest server

后端 未结 5 967
长发绾君心
长发绾君心 2021-02-09 07:01

I created a rest server using the codeigniter rest server library created by PhilSturgeon :

github.com/philsturgeon/codeigniter-restserver

Now, I am using Codei

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-09 07:33

    After searched for more than 1 days, finally this is what worked for me

    public function upload_post()
        {
          $config['upload_path'] = './uploads/';
          $config['allowed_types'] = '*';
    
          $this->load->library('upload');
          $this->upload->initialize($config);
    
          if ( ! $this->upload->do_upload('file'))
          {
            $error = array('error' => $this->upload->display_errors());
             print_r($error);
          //  $this->load->view('upload_form', $error);
          }
          else
          {
            $data = array('upload_data' => $this->upload->data());
            print_r($data);
          //  $this->load->view('upload_success', $data);
          }
        }
    

提交回复
热议问题