laravel上传图片
2021-03-19 01:26
标签:getc too data vat ejs origin 图片 func gate laravel上传图片 标签:getc too data vat ejs origin 图片 func gate 原文地址:https://www.cnblogs.com/cjjjj/p/12762577.html 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‘, ‘上传失败‘);
}
}