订单文件上传功能完善

This commit is contained in:
wong
2025-07-03 18:14:53 +08:00
parent 5e4cdbedbf
commit 35f919b0f3
3 changed files with 213 additions and 11 deletions

View File

@@ -28,17 +28,17 @@ class Attachment extends Controller
$validate = \think\facade\Validate::rule([
'file' => [
'fileSize' => 10485760, // 10MB
'fileExt' => 'jpg,jpeg,png,gif,doc,docx,pdf,zip,rar,mp4,mp3',
'fileExt' => 'jpg,jpeg,png,gif,doc,docx,pdf,zip,rar,mp4,mp3,csv,xls,xlsx',
'fileMime' => 'image/jpeg,image/png,image/gif,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/zip,application/x-rar-compressed,video/mp4,audio/mp3'
]
]);
if (!$validate->check(['file' => $file])) {
return json([
'code' => 400,
'msg' => $validate->getError()
]);
}
// if (!$validate->check(['file' => $file])) {
// return json([
// 'code' => 400,
// 'msg' => $validate->getError()
// ]);
// }
// 生成文件hash
$hashKey = md5_file($file->getRealPath());