Guzzle上传文件(携带翻墙参数)

不得不说guzzle这个包真是无敌的好用,能够解决各种需求,今天我们来倒腾一下文件上传

代码

$client = new Client();
            $pa = $_SERVER['HTTP_ORIGIN'];
            $domain = parse_url($pa)['host'];
            $cookie_arr = [
                'PHPSEXXX' => '12345678',
            ];
            $cookieJar = CookieJar::fromArray($cookie_arr, $domain);
            $file_name = '';
            $file_name = '../xxx' . $la_code . '.pdf';
            $r = $client->request('POST', $pa . '/checkingxxxx/upfiles', [
                'cookies' => $cookieJar,
                'multipart' => [
                    [
                        'name' => 'file_name[]',
                        'contents' => fopen($file_name, 'r')
                    ],
                    [
                        'name' => 'id_link',
                        'contents' => $value
                    ],
                ]
            ]);

推荐阅读更多精彩内容