服务器端未收到 POST 数据

fri*_*ndq 0 php apache post http-post

我使用 Postman(Chrome 应用程序)将 POST 数据发送到 URL,但 PHP 文件永远不会收到 POST 数据,无论我在发送前如何更改内容类型。Apache 上是否有停止从外部来源发布数据的服务器设置?

这是网址:http : //friendesque.com/arranged/handler.php

这是 handler.php 文件的内容:

<?php
     echo("Inside file");

     echo("JSON:");
     $json = file_get_contents('php://input');
     echo($json);

     echo("POST:");
     print_r($_POST);

     echo("GET:");
     print_r($_GET);
?>
Run Code Online (Sandbox Code Playgroud)

jed*_*ylo 5

为了使$_POST数组中的数据可用,应满足以下条件:

  1. 请求必须使用POST HTTP 方法发送
  2. Content-Type 标头必须设置为application/x-www-form-urlencoded
  3. 请求负载(主体)必须采用URL 编码参数的形式,例如

    param1=a&param2=b
    
    Run Code Online (Sandbox Code Playgroud)

我向您的 URL 发送了一个满足这 3 个条件的请求,并在$_POST数组中获取了我的数据。