Post JSON to Codeigniter controller

后端 未结 12 1069
鱼传尺愫
鱼传尺愫 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条回答
  •  萌比男神i
    2020-12-30 05:19

    In order to use the standard CI methods. In index.php, insert a couple of lines:

        $json = json_decode(trim(file_get_contents('php://input')), true);
        if(!empty($json)) {
            $_POST = $json;
        }
    

    Either implement in the bootstrap. RIP Codigniter...(

提交回复
热议问题