Unity 2017.3.0f3发布数据未发送到LAMP服务器 [英] Unity 2017.3.0f3 post data not being sent to LAMP server

查看:128
本文介绍了Unity 2017.3.0f3发布数据未发送到LAMP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我的cpanel/WHM服务器可能已经 (尽管我不确定是什么原因)已通过一些安全设置进行了设置,其中PHP无法接收从其他域发布的表单数据/电脑/设备...

It looks like my cpanel/WHM server has probably (though I am not sure what is the cause) been set with some security settings, where PHP is not receiving form data posted from other domains / computers / devices...

我已经测试了空的$ _REQUEST(以及$ _POST-以防万一)转储是否有发布数据,其中原始数据来自另一台设备.

I've tested null $_REQUEST (and also $_POST - just in case) dump for post data where the origin comes to the server from another device.

  • 我也尝试过在PHP header("access-control-allow-origin: *");

我还在父目录和php Header set Access-Control-Allow-Origin "*"

I have also set in .htaccess in both the parent directory and the directory of the php Header set Access-Control-Allow-Origin "*"

作为一个健全性检查,我已经尝试过使用准系统php,没有cookie.仅当发送post变量的脚本来自同一服务器时,此命令才会显示,而在其他地方<?php print_r($_REQUEST)

as a sanity check, i've tried it with barebones php, no cookies. this will only print if the script sending post variables is from the same server, but will not work if it's elsewhere <?php print_r($_REQUEST)

来自客户端的标头响应:

Header response from client:

有没有一种方法可以停止但可以允许从任何来源发布数据?

Is there a way not to stop but to allow post data from any source?

(还进行完整性检查,测试从远程设备发布到服务器的客户端脚本,以便在 https://posttestserver.com上工作/-因此,这肯定是PHP服务器不接受发布字段)

(Also for a sanity check, tested client script from remote device posting to server to work on https://posttestserver.com/ - so it is definitely PHP server not accepting post fields)

推荐答案

显然,在Unity 2017.3.0f3 request.chunkedTransfer(来自request = new UnityWebRequest)中,将其设置为true,将其设置为false则允许php://input流变量要经历.

Apparently, in Unity 2017.3.0f3 request.chunkedTransfer (from request = new UnityWebRequest) is set to true, setting it to false allows for the php://input stream variables to go through.

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

However, depending on how you are encoding the form, $_REQUEST and $_POST are still null arrays until request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); is added...


request.chunkedTransfer = false; // just this might work if you are using WWWForm
request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");

这篇关于Unity 2017.3.0f3发布数据未发送到LAMP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆