This time I will bring you Post’s inability to obtain form data. What are the precautions to solve Post’s inability to obtain form data? The following is a practical case, let’s take a look.
Problem description
When using vue-axios to post data to the backend, the PHP side cannot obtain the posted data.Problem Solving
Modify php.ini configurationFind the php.iniconfiguration file, find the enable_post_data_reading variable, and modify it to Open the state, comment out the prefix
; 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行,修改此条
$raw = file_get_contents('php://input');//获取非表单数据 echo $raw;//输出结果
headers: { "Content-type": "application/json; charset=utf-8" }
php custom two-dimensional array sorting function array
implementation of phpunit interface automated testing function
The above is the detailed content of Post cannot get form data. For more information, please follow other related articles on the PHP Chinese website!