PHP “php://input” vs $_POST

前端 未结 6 1926
离开以前
离开以前 2020-11-21 23:55

I have been directed to use the method php://input instead of $_POST when interacting with Ajax requests from JQuery. What I do not understand is t

6条回答
  •  抹茶落季
    2020-11-22 00:18

    If post data is malformed, $_POST will not contain anything. Yet, php://input will have the malformed string.

    For example there is some ajax applications, that do not form correct post key-value sequence for uploading a file, and just dump all the file as post data, without variable names or anything. $_POST will be empty, $_FILES empty also, and php://input will contain exact file, written as a string.

提交回复
热议问题