PHP Settings? PHP not receiving POST data

后端 未结 5 870
天涯浪人
天涯浪人 2020-12-20 21:36

I’m sending a .php file POST data from a java application. The .php file is not accepting the POST data. file_get_contents(‘php://input’) is empty and $_POST is empty. I kno

相关标签:
5条回答
  • 2020-12-20 21:54

    If the Content-Type is empty or not recognized in the HTTP message then the PHP $_POST array is empty. If you cannot send the Content-Type you can add this to your PHP:

    if(empty($_SERVER['CONTENT_TYPE']))
    { 
     $_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded"; 
    }
    

    You can also check if you have the correct settings in your php.ini

    ; Maximum size of POST data that PHP will accept.
    post_max_size = 8M
    

    If post_max_size is 0, PHP will not populate $_POST.

    variables_order = "EGPCS"
    

    If you do not have P in there, $_POST will not be set either.

    0 讨论(0)
  • 2020-12-20 22:00

    I was having the same problem. It turned out to be because I was prefixing my target with http . I changed it to https and it worked.

    0 讨论(0)
  • 2020-12-20 22:05

    i had this problem too, for future visitors, my issue was missing the trailing slash in the url

    http://someplace.com/cheeseburger
    

    should have been

    http://someplace.com/cheeseburger/
    

    for example. this was causing the post to fail in my case.

    0 讨论(0)
  • 2020-12-20 22:05

    My problem was duplicate names for an input.

    ex: /input name="test" type="text" / /input name="test" type="text" /

    each must have a different name ex: /input name="testA" type="text" / /input name="testB" type="text" /

    0 讨论(0)
  • 2020-12-20 22:13

    I had the same issue. The problem was http:// and https://

    0 讨论(0)
提交回复
热议问题