Unity 2017.3.0f3发布数据未发送到LAMP服务器

问题描述 投票:2回答:1

看起来我的cpanel / WHM服务器可能(虽然我不确定是什么原因)设置了一些安全设置,其中PHP没有接收从其他域/计算机/设备发布的表单数据...

我已经测试了null $ _REQUEST(以及$ _POST - 以防万一)转储后发布数据,其中源自另一个设备到达服务器。

  • 我也在PHP header("access-control-allow-origin: *");中尝试过CORS设置
  • 我还在父目录和php Header set Access-Control-Allow-Origin "*"的目录中设置了.htaccess
  • 作为一个完整性检查,我尝试使用准系统php,没有cookie。这只会在发送post变量的脚本来自同一服务器时打印,但如果它在其他地方则无法工作<?php print_r($_REQUEST)

来自客户的标题回复:enter image description here

有没有办法不停止,但允许从任何来源发布数据?

(也是为了进行健全性检查,测试客户端脚本从远程设备发布到服务器以在https://posttestserver.com/上工作 - 所以它肯定是PHP服务器不接受帖子字段)

php apache unity3d cpanel lamp
1个回答
2
投票

显然,在Unity 2017.3.0f3中,request.chunkedTransfer(来自request = new UnityWebRequest)设置为true,将其设置为false允许php://输入流变量通过。

但是,根据您对表单的编码方式,$ _REQUEST和$ _POST仍为空数组,直到添加request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");为止...

request.chunkedTransfer = false; // just this might work if you are using WWWForm
request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
© www.soinside.com 2019 - 2024. All rights reserved.