get()); $http = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . $token . '&type=image'; $response = Curl::to($http) ->withData([ 'media' => "@{$filename}" ]) ->withFile('chat_' . uniqid(), $filename) ->post(); \File::delete($filename); $result = json_decode($response, true); if (isset($result['errcode'])) { return ['code' => $result['errcode'], 'msg' => $result['errmsg']]; } else { return ['code' => 0, 'msg' => 'OK', 'data' => $result]; } } }