Post JSON to Codeigniter controller

后端 未结 12 1080
鱼传尺愫
鱼传尺愫 2020-12-30 05:03

I am trying to receive and parse a JSON object sent in a POST request using Codeigniter but I cannot \"find\" it.

This is my controller code:

public          


        
12条回答
  •  半阙折子戏
    2020-12-30 05:11

    $post = json_decode($this->security->xss_clean($this->input->raw_input_stream));
    

    When you use $this->input->raw_input_stream you can read it multiple times and its basically the same as file_get_contents('php://input'). This works on CI3. I don't know if it works on CI2.

提交回复
热议问题