php $_POST array empty upon form submission

前端 未结 27 3396

I have a custom CMS i\'ve built that works perfectly on my dev box (Ubuntu/PHP5+/MySQL5+).

I just moved it up to the production box for my client and now all form su

27条回答
  •  甜味超标
    2020-11-22 09:43

    I know this question was about POST via a Form, but came here looking for answers for similar issue when POSTing with JSON content-type. Found the answer and wanted to share it as it cost me much time.

    When using JSON content-type the $_POST array will not populate (only with multi-part forms I believe)

    Here is what did work to correct the issue:

    $rest_json = file_get_contents("php://input");
    $_POST = json_decode($rest_json, true);
    

    hope this helps someone!

提交回复
热议问题