update
This commit is contained in:
@ -69,10 +69,10 @@ class UploadController extends AbstractController
|
||||
}
|
||||
|
||||
// 校验类型
|
||||
$allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
|
||||
if (!in_array($file->getClientMediaType(), $allowedTypes)) {
|
||||
return $this->response->json(['code' => 415, 'msg' => '不支持的图片格式']);
|
||||
}
|
||||
// $allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
|
||||
// if (!in_array($file->getClientMediaType(), $allowedTypes)) {
|
||||
// return $this->response->json(['code' => 415, 'msg' => '不支持的图片格式']);
|
||||
// }
|
||||
|
||||
// 限制大小 (例如 5MB)
|
||||
$maxSize = 5 * 1024 * 1024;
|
||||
@ -82,7 +82,7 @@ class UploadController extends AbstractController
|
||||
|
||||
// 保存路径
|
||||
$filename = uniqid() . '.' . pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
|
||||
$targetPath = BASE_PATH . '/uploads/' . $filename;
|
||||
$targetPath = BASE_PATH . '/public/uploads/' . $filename;
|
||||
|
||||
// 确保目录存在
|
||||
if (!is_dir(dirname($targetPath))) {
|
||||
@ -98,7 +98,7 @@ class UploadController extends AbstractController
|
||||
|
||||
return $this->response->json([
|
||||
'errno' => 0,
|
||||
'msg' => '上传成功!!',
|
||||
'msg' => '上传成功!!~',
|
||||
'data' => [
|
||||
'url' => Config::getDomain() . $url,
|
||||
]
|
||||
|
Reference in New Issue
Block a user