Home  >  Q&A  >  body text

javascript - axios uses x-www-form-urlencoded, POST form PHP prompt is outdated

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梦2660 days ago1014

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-06-14 10:51:57

    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.

    reply
    0
  • typecho

    typecho2017-06-14 10:51:57

    //接受 post
    $data = file_get_contens('php://input');

    reply
    0
  • Cancelreply