最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP Post獲取不到非表單數(shù)據(jù)的問題解決辦法

 更新時間:2018年02月27日 10:58:19   投稿:laozhang  
這篇文章主要介紹了PHP Post獲取不到非表單數(shù)據(jù)的問題的解決辦法以及代碼分享,需要的朋友參考下。

問題描述

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

問題解決

修改php.ini配置

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

; 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-reading
enable_post_data_reading = On  //大約656行,修改此條

修改配置后,發(fā)現(xiàn)還是不行,繼續(xù)查閱資料。

獲取非表單數(shù)據(jù)

搜集資料之后,發(fā)現(xiàn)vue-axios向后端post的是非表單數(shù)據(jù)(Ajax不同),在獲取非表單數(shù)據(jù)時需要用php://input

$raw = file_get_contents('php://input');//獲取非表單數(shù)據(jù)
echo $raw;//輸出結(jié)果

PS:post時前端請求頭要設(shè)置為

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

相關(guān)文章

最新評論

宿迁市| 大连市| 定远县| 宁南县| 贵定县| 镇雄县| 镇康县| 吴川市| 钦州市| 霞浦县| 泰州市| 讷河市| 武川县| 陇南市| 色达县| 汤阴县| 青浦区| 锡林浩特市| 井研县| 含山县| 渭南市| 博爱县| 宁强县| 庆安县| 永年县| 应城市| 英吉沙县| 泗水县| 蒲城县| 南和县| 麻城市| 敦煌市| 吉安县| 溧阳市| 宣恩县| 仁布县| 突泉县| 通山县| 温宿县| 洛川县| 女性|