|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-12-28 01:22 UTC] manhiro at gmail dot com
Description:
------------
Apache 2.4.6
PHP 7.1.12
I'm trying to manually parse multipart form data on PHP-FPM.
When I set the 'enable_post_data_reading = Off' in php.ini file, I can get raw post data.
Example:
$handle = fopen("php://input", "rb");
while (!feof($handle)) {
// do something
}
However, when I set that in .user.ini file, I can't get raw post data.
I think that the .user.ini file is correct because phpinfo() shows as bellow.
Local Value | Master Value
----------------------------
Off | On
Note:
sapi_activate() in the file main/SAPI.c:
----------------------------
/* Handle request method */
if (SG(server_context)) {
if (PG(enable_post_data_reading)
&& SG(request_info).content_type
&& SG(request_info).request_method
&& !strcmp(SG(request_info).request_method, "POST")) {
/* HTTP POST may contain form data to be processed into variables
* depending on given content type */
sapi_read_post_data();
} else {
SG(request_info).content_type_dup = NULL;
}
/* Cookies */
SG(request_info).cookie_data = sapi_module.read_cookies();
}
if (sapi_module.activate) {
sapi_module.activate();
}
if (sapi_module.input_filter_init) {
sapi_module.input_filter_init();
}
----------------------------
I guess that the above code to handle request method is executed before loading .user.ini file.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
I tried on php7.2.1. However, it didn't work. Test script: --------------- //test.html <html> <head> <title>test</title> </head> <body> <form action="upload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="test" /><br> <input type="submit" /> </form> </body> </html> //upload.php <?php var_dump($_FILES); //.user.ini enable_post_data_reading = Off upload_max_filesize = 10M phpinfo result: ---------------- Local Value | Master Value ---------------------------- Off | On Expected result: ---------------- array(0) { } Actual result: -------------- array(1) { ["test"]=> array(5) { ["name"]=> string(21) "test.mp4" ["type"]=> string(9) "video/mp4" ["tmp_name"]=> string(14) "/tmp/php9fldnI" ["error"]=> int(0) ["size"]=> int(5230167) } }