file_get_contents('php://input') always returns an empty string

后端 未结 12 2220
遥遥无期
遥遥无期 2020-12-09 09:04

I\'m building a PHP RESTful API, following this tutorial. The following function, which should return the data sent with the request when the \'put\' method is used, returns

12条回答
  •  借酒劲吻你
    2020-12-09 09:30

    I had the same problem. Eventually, I found that the problem was that in the client side I didn't stringify the json object (previously I used nodejs server and it was OK). Once I did that, I received the data in $_POST (not as json), as regular parameters.

提交回复
热议问题