...
|
...
|
@@ -132,4 +132,42 @@ class UploadFile |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 验证
|
|
|
* @param array $rule
|
|
|
* @param bool $throw
|
|
|
* @throws Err
|
|
|
* @author:dc
|
|
|
* @time 2023/4/18 10:55
|
|
|
*/
|
|
|
public function verify(array $rule,bool $throw = true){
|
|
|
$this->lastVerifyError = '';
|
|
|
// 后缀
|
|
|
if(!empty($rule['ext'])){
|
|
|
$rule['ext'] = is_string($rule['ext']) ? [$rule['ext']] : [];
|
|
|
if (!in_array($this->ext,$rule['ext'])){
|
|
|
if(!$throw) return false;
|
|
|
app()->e(['verify_file.ext',['',$this->name,implode('|',$rule['ext'])]],600);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 类型
|
|
|
if(!empty($rule['mine'])){
|
|
|
$rule['mine'] = is_string($rule['mine']) ? [$rule['mine']] : [];
|
|
|
if (!in_array($this->mime,$rule['mine'])){
|
|
|
if(!$throw) return false;
|
|
|
app()->e(['verify_file.mine',['',$this->name,implode('|',$rule['mine'])]],600);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 大小
|
|
|
if(!empty($rule['size'])){
|
|
|
if ($this->size > $rule['size']){
|
|
|
if(!$throw) return false;
|
|
|
app()->e(['verify_file.size',['',$this->name,$rule['size']]],600);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|