gpt4 book ai didi

php - 无法使用 file_get_contents ('php://input' 检索原始发布数据)

转载 作者:行者123 更新时间:2023-12-04 01:55:09 27 4
gpt4 key购买 nike

这是我的代码。我正在使用 post 方法发布我的数据。

$post_body = file_get_contents('php://input');
if(getenv('REQUEST_METHOD') == 'POST'){
print_r( array( "3","3d"));
}
print_r($post_body);

我正在使用 chrome 的 postman 来测试此代码,但它不打印发布数据,请参阅输出图像。

output image

我做错了什么???

编辑

为了展示我是如何解决我的问题的,我添加了这张图片。

To show

最佳答案

根据 PHP documentation

php://input is not available with enctype="multipart/form-data".

Postman 支持不同类型的 Content-Type 包括 multipart/form-data 这似乎是默认的。

因此请确保您不使用multipart/form-data(在Body 选项卡中)。

关于php - 无法使用 file_get_contents ('php://input' 检索原始发布数据),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37019791/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com