1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > PHP中Post获取不到非表单数据如何解决

PHP中Post获取不到非表单数据如何解决

时间:2021-03-21 17:15:38

相关推荐

PHP中Post获取不到非表单数据如何解决

web前端|js教程

Post,php,数据

web前端-js教程

在使用vue-axios向后端post数据时,PHP端获取不到post的数据。本文主要和大家分享PHP中Post获取不到非表单数据如何解决,希望能帮助到大家。

php微信框架源码下载,ubuntu没有小键盘,python爬虫技术简介,php 环境打包,seo成功核心lzw

问题解决

php直播系统源码下载,vscode如何添加监视,ubuntu raid配置,tomcat只用ip访问,安卓手机怎么连接sqlite,爬虫如何在闲鱼选品里搜索,mac php版本升级,seo专业推广平台,网站开源程序下载,怎么调用模板页的方法lzw

修改php.ini配置

找到php.ini配置文件,查找enable_post_data_reading变量,修改为打开状态,注释掉句前分好

一元后夺宝源码,vscode背景特效插件,ubuntu 字体缺失,tomcat取消日志输出,启动爬虫,rijndael php,开化网络营销seo,seo外链发布网站源码,商城电子模板免费下载lzw

; Whether PHP will read the POST data.; This option is enabled by default.; Most likely, you won want to disable this option globally. It causes $_POST; and $_FILES to always be empty; the only way you will be able to read the; POST data will be through the php://input stream wrapper. This can be useful; to proxy requests or to process the POST data in a memory efficient fashion.; /enable-post-data-readingenable_post_data_reading = On //大约656行,修改此条

修改配置后,发现还是不行,继续查阅资料。

获取非表单数据

搜集资料之后,发现vue-axios向后端post的是非表单数据(Ajax不同),在获取非表单数据时需要用php://input

$raw = file_get_contents(php://input);//获取非表单数据echo $raw;//输出结果

PS:post时前端请求头要设置为

headers: { "Content-type": "application/json; charset=utf-8"}

php $_POST获取html表单form数据教学_PHP教学

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。