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

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

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

問(wèn)題描述

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

問(wèn)題解決

修改php.ini配置

找到php.ini配置文件,查找enable_post_data_reading變量,修改為打開(kāi)狀態(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ù)時(shí)需要用php://input

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

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

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

相關(guān)文章

最新評(píng)論

息烽县| 库伦旗| 大连市| 信丰县| 鹤壁市| 渑池县| 双城市| 出国| 和政县| 德令哈市| 河间市| 五莲县| 南乐县| 行唐县| 随州市| 武安市| 泰安市| 桐乡市| 施甸县| 安陆市| 客服| 齐河县| 东丽区| 潢川县| 五峰| 旌德县| 阳东县| 平远县| 东丽区| 阿拉善右旗| 左云县| 万荣县| 江阴市| 东山县| 乐清市| 西华县| 衡山县| 洛阳市| 乳源| 安多县| 大厂|