refactor: 修改图片上传区分模块
This commit is contained in:
@@ -12,6 +12,10 @@ class Images
|
||||
// 上传
|
||||
public function upload()
|
||||
{
|
||||
$param = request()->param(['module']);
|
||||
if (is_null($param)) {
|
||||
return error('请确定请求参数正确');
|
||||
}
|
||||
$file = request()->file('image');
|
||||
if (is_null($file)) {
|
||||
return error('请确定上传对象或字段是否正确');
|
||||
@@ -19,9 +23,10 @@ class Images
|
||||
|
||||
try {
|
||||
$validate = validate([
|
||||
'image'=>'fileSize:1048576|fileExt:jpg,jpeg,png,gif'
|
||||
'module' => 'require|max:64',
|
||||
'image' => 'fileSize:1048576|fileExt:jpg,jpeg,png,gif'
|
||||
]);
|
||||
if (!$validate->check(['image' => $file])) {
|
||||
if (!$validate->check(['module' => $param['module'], 'image' => $file])) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
@@ -44,7 +49,7 @@ class Images
|
||||
$image_model = new ImageModel();
|
||||
}
|
||||
$image_model->language_id = request()->lang_id;
|
||||
$image_model->image_name = $file->getOriginalName();
|
||||
$image_model->module = $param['module'];
|
||||
$image_model->image_path = $filename;
|
||||
$image_model->image_thumb = $thumb_filename;
|
||||
$image_model->image_size = $file->getSize();
|
||||
|
||||
Reference in New Issue
Block a user