**guzzle** 是发送网络请求的类库
composer安装:**composer require guzzlehttp/guzzle**
中文文档[**https://guzzle-cn.readthedocs.io/zh_CN/latest/quickstart.html**]
use GuzzleHttp\Client;
public $upload_type; // 发送类型 'image|video|file'
public function shopUpload ($name)
$file = fopen($_FILES[$name]['tmp_name'], 'r')
$response = (new Client())->request(
'POST', //post 请求
'http://www.xxx.cm/upload',
// name: (必须,字符串) 映射到表单字段的名称。
// contents: (必须,混合) 提供一个字符串,可以是 fopen 返回的资源、或者一个
'multipart' => [ //设置
'name' => $name,
'contents' => $file,
'filename' => $_FILES[$name]['name'],
'type' => $_FILES[$name]['type']
'name' => 'file_name', // 上传表单的name值
'contents' => $name
'name' => 'upload_type', // 上传文件类型
'contents' => $this->upload_type,
$resultMap = json_decode($response->getBody()->getContents(), true);
服务器接收
function upload ()
直接获取 $_FILES;