javascript - axios uses x-www-form-urlencoded, POST form PHP prompt is outdated
过去多啦不再A梦
过去多啦不再A梦 2017-06-14 10:49:57
0
2
1051

Return results

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

1 The following js will report out of date

axios.post('/api/code/create', this.formItem)

2 The following js will not report an error

axios.post('/api/code/create', window.qs.stringify(this.formItem))

But using method 2, the boolean data in this.formItem will become "True" / "False"
As a result, fields with field type bool in mysql cannot be saved as "True" when stored in the database. The corresponding 1 is always 0

I don’t want to modify php.ini, I use laravel5.2
Code to get data

Input::all();

How to avoid errors and store them correctly? If using php://input, how to modify it?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
洪涛

Not POST forms are obsolete. Did you use software to do the translation?

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version.

This sentence means that the $HTTP_RAW_POST_DATA constant is obsolete and will be removed in the next version.

But this version still exists, and this is a warning.

The solution is given below.

2 types:

  • In the php.ini configuration file, set always_populate_raw_post_data to -1

  • Don’t use $HTTP_RAW_POST_DATA, use php://input instead.

typecho
//接受 post
$data = file_get_contens('php://input');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!