<?php
Swoole\Coroutine\Http\Client->addFile(string $path, string $name, string $mimeType = null, string $filename = null, int $offset = 0, int $length = 0)
The location of the file
The file name
mimeType
filename
offset
length
Attach files for the HTTP request.
<?php
use Swoole\Coroutine\HTTP\Client;
Co\run(function() {
$cli = new Swoole\Coroutine\Http\Client('httpbin.org', 80);
$cli->setHeaders([
'Host' => "httpbin.org"
]);
$cli->set(['timeout' => -1]);
$cli->addFile(__FILE__, 'file1', 'text/plain');
$cli->post('/post', ['foo' => 'bar']);
echo $cli->body;
$cli->close();
});