laravel上传图片
public function uploadFilePrivate(Request $request) { $file = array_get($request, 'file', ''); if (empty($file)) { return $this->responseJson([], -1, '文件不能为空'); } $data = [ 'file' => new \CURLFile($file->getPathname(), $file->getClientMimeType(), $file->getClientOriginalName()), ]; try { $result = Gateway::tool('/v1/file/private', $data, 'POST'); $result['origin_name'] = $file->getClientOriginalName(); return $this->responseJson($result); } catch (\Exception $e) { return $this->responseJson([], '-1', '上传失败'); } }