In PHP, request_parse_body() reads the raw HTTP request body and parses application/x-www-form-urlencoded or multipart/form-data data into a structure like $_POST and $_FILES.
It is available in PHP 8.4+. The main use is parsing multipart bodies for verbs other than POST, which do not fill the normal superglobals automatically. It returns a two-item array: index 0 is the post fields, index 1 is the files list.
Syntax
Call request_parse_body() with the values you need. Start with this line.
PHP
[$_POST, $_FILES] = request_parse_body();
Call
What it does
request_parse_body()
Parses the current request body with the default php.ini limits.
request_parse_body(['post_max_size' => '10M'])
Overrides selected upload and body size settings for this parse only.
[$post, $files] = request_parse_body()
Destructures the [post, files] pair into two variables.
The optional $options array may override keys such as post_max_size, upload_max_filesize, max_file_uploads, max_input_vars, and max_multipart_body_parts. The body can be consumed only once; reading php://input first can leave this function empty.
Library declarations
PHP
request_parse_body(?array $options = null): array
Parameters
Parameter
Description
options
Optional. Associative array of php.ini-style limits for this parse, or null to use the global settings.
Return Value
Return Value
Description
array
A two-element array: [0] post fields (like $_POST), [1] uploaded files (like $_FILES).
PHP Examples
Example 1 — Parse a Form Body into Post and Files
Show the usual destructuring call. The View Output below is a fixed sample of a successful parse.