swoole_http_client->addFile
���POST���
function swoole_http_client->addFile(string $path, string $name, string $filename = null, string $mimeType = null)
- $path �ļ���·������ѡ����������Ϊ���ļ����߲����ڵ��ļ�
- $name �������ƣ���ѡ������FILES�����е�key
- $filename �ļ����ƣ���ѡ������Ĭ��Ϊ
basename($path) - $mimeType �ļ���MIME��ʽ����ѡ�������ײ������ļ�����չ���Զ��ƶ�
ʹ��addFileֻ��POST��Content-Type�����Ϊform-data��addFile�ײ����sendfile����֧���첽���ͳ����ļ���
addFile��1.8.9����߰汾����
ʹ��ʾ��
$cli = new swoole_http_client('127.0.0.1', 80);
//post request
$cli->setHeaders(['User-Agent' => "swoole"]);
$cli->addFile(__DIR__.'/post.data', 'post');
$cli->addFile(dirname(__DIR__).'/test.jpg', 'debug');
$cli->post('/dump2.php', array("xxx" => 'abc', 'x2' => 'rango'), function ($cli) {
echo $cli->body;
});