国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

PHP Post獲取不到非表單數據的問題解決辦法

2024-05-05 00:02:32
字體:
來源:轉載
供稿:網友

問題描述

在使用vue-axios向后端post數據時,PHP端獲取不到post的數據。

問題解決

修改php.ini配置

找到php.ini配置文件,查找enable_post_data_reading變量,修改為打開狀態,注釋掉句前分好

; Whether PHP will read the POST data.; This option is enabled by default.; Most likely, you won't 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.; http://php.net/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教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 迭部县| 仪征市| 淄博市| 伊川县| 宜章县| 绥宁县| 安新县| 潼南县| 临洮县| 巩留县| 通州区| 贡嘎县| 常宁市| 临城县| 盐边县| 文成县| 平舆县| 塔河县| 城步| 沁阳市| 昔阳县| 永丰县| 都江堰市| 庄河市| 射阳县| 杭锦旗| 青冈县| 新河县| 麻江县| 松滋市| 交城县| 马公市| 惠水县| 梅河口市| 图们市| 玉屏| 桓仁| 德钦县| 藁城市| 云霄县| 浮山县|