FIle upload from a rest client to a rest server

后端 未结 5 980
长发绾君心
长发绾君心 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:32

    Simple Rest Post service to upload & store a file from any Rest client

    public function product_post()
    {
        $uploaddir = './uploads/products/';
        $file_name = underscore($_FILES['file']['name']);
        $uploadfile = $uploaddir.$file_name;
    
        if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
            $dataDB['status'] = 'success';       
            $dataDB['filename'] = $file_name;
         } else {
            $dataDB['status'] =  'failure';       
         }
         $this->response($dataDB, 200);
    }
    

提交回复
热议问题