php cannot receive data
The form form is a very commonly used html tag, which can submit data for us to the server, upload files, etc. Sometimes the background program cannot receive data. Let's take a look at the solution.
1. $_POST cannot receive data, but $_GET can receive data.
1. If the header information content-type is "content-type :application/x-www-form-urlencoded", this transmission is to submit data in the form of a form, and PHP uses the$_POSTmethod to accept it.
2. If the header information content-type is "content-type:application/json", this transmission is to submit data in json mode, and PHP needs to usefile_get_contents("php://input" )Accept the way to get the input stream.
2. When uploading files, $_POST data and $_FILES data cannot be received
Cause: The file size exceeds the post_max_size set by php.ini, resulting in POST data is empty, and the FILES data is also empty.
Solution:
1. The simplest is to set the file sizepost_max_sizelarger in php.ini and then restart the server.
2. Or use JS on the page to prompt the user, please upload a file of a specified size.
For more PHP related knowledge, please visitPHP Chinese website!
The above is the detailed content of php cannot receive data. For more information, please follow other related articles on the PHP Chinese website!