...
|
...
|
@@ -169,12 +169,12 @@ class Verify { |
|
|
/**
|
|
|
* 必须
|
|
|
* @param $key
|
|
|
* @return false
|
|
|
* @return bool
|
|
|
* @author:dc
|
|
|
* @time 2023/3/13 10:11
|
|
|
* @time 2023/3/13 17:14
|
|
|
*/
|
|
|
public function required($key){
|
|
|
return $this->_get($key) !== '';
|
|
|
return $this->_get($key) !== '' || app()->file($key);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -388,7 +388,37 @@ class Verify { |
|
|
* @time 2023/3/13 14:27
|
|
|
*/
|
|
|
public function file($key,$value){
|
|
|
$files = app()->file($key);
|
|
|
if($files){
|
|
|
foreach ($files as $file){
|
|
|
// 后缀
|
|
|
if(!empty($value['ext'])){
|
|
|
$value['ext'] = is_string($value['ext']) ? [$value['ext']] : [];
|
|
|
if (!in_array($file->ext,$value['ext'])){
|
|
|
app()->e(['verify_file.ext',[$this->alias[$key],$file->name,implode('|',$value['ext'])]],600);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 类型
|
|
|
if(!empty($value['mine'])){
|
|
|
$value['mine'] = is_string($value['mine']) ? [$value['mine']] : [];
|
|
|
if (!in_array($file->mime,$value['mine'])){
|
|
|
app()->e(['verify_file.mine',[$this->alias[$key],$file->name,implode('|',$value['mine'])]],600);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 大小
|
|
|
if(!empty($value['size'])){
|
|
|
if ($file->size > $value['size']){
|
|
|
app()->e(['verify_file.size',[$this->alias[$key],$file->name,$value['size']]],600);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|