client centos6.9, php7.1.21 use swoole_http_client through post data and upload files to the server:
$data = [
"p1" => 1,
"p2" => 2,
"groups" => [20,30]
];
$cli->addFile("/home/test/photo.jpg", "photo");
$cli->post("/index.php", $data, function ($cli) {
echo $cli->body;
});
Server centos6.9, php7.1.21, apache2.2.15 ordinary web applications: index.php
var_export($_POST);
exit;
the data typed out in the result is: ( the array is converted to "Array"! )
array(
"p1" => 1,
"p2" => 2,
"groups" => "Array"
)
but what I expect is:
array(
"p1" => 1,
"p2" => 2,
"groups" => array(20,30)
)
above, where is the problem with the use, or is it the problem of swoole_http_client itself?
if you do not call the addFile file, the result is normal. It is said in the swoole document that the general post is application/x-www-form-urlencoded, and will be converted to form-data, after using addFile. Is there a problem with swoole conversion?