您好,登錄后才能下訂單哦!
如何解決php獲取不到form數(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"}
以上就是如何解決php獲取不到form數(shù)據(jù)的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注億速云其它相關(guān)文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。