【发布时间】:2018-01-17 10:45:16
【问题描述】:
从另一个域发布表单(使用 POST)时,我的 POST 集合为空。 当我在同一个域上使用一个简单的 HTML 页面进行测试时,它可以工作。
这是我的 PHP 代码:
<?php
header("access-control-allow-origin: *");
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
ini_set("allow_url_fopen", true);
echo("input: " . file_get_contents("php://input"));
?>
有人有想法吗?会不会是服务器设置/配置?
这些是我返回的标题(使用 Postman 时):
Connection →Upgrade, Keep-Alive
Content-Encoding →gzip
Content-Length →27
Content-Type →text/html; charset=UTF-8
Date →Wed, 17 Jan 2018 10:39:26 GMT
Keep-Alive →timeout=2, max=100
Server →Apache/2.4.29 (Unix) OpenSSL/1.0.2k
Upgrade →h2,h2c
Vary →Accept-Encoding,User-Agent
X-Powered-By →PHP/7.2.0
access-control-allow-origin →*
【问题讨论】:
-
请分享请求代码。