...
|
...
|
@@ -100,7 +100,7 @@ class UploadFile |
|
|
$ext = explode('.',$name);
|
|
|
$this->ext = end($ext);
|
|
|
|
|
|
$this->savePath = PUBLIC_PATH.'/storage/';
|
|
|
$this->savePath = PUBLIC_PATH;
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -118,7 +118,7 @@ class UploadFile |
|
|
}
|
|
|
|
|
|
// 保存的文件
|
|
|
$this->saveName = $name ? $name : md5_file($this->tempFile).'.'.$this->ext;
|
|
|
$this->saveName = '/storage/'.($name ? $name : md5_file($this->tempFile).'.'.$this->ext);
|
|
|
|
|
|
if($this->isUpload){
|
|
|
return move_uploaded_file($this->tempFile,$this->savePath.$this->saveName);
|
...
|
...
|
@@ -141,22 +141,19 @@ class UploadFile |
|
|
* @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);
|
|
|
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);
|
|
|
app()->e(['verify_file.mine',[' ',$this->name,implode('|',$rule['mine'])]],600);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -164,9 +161,10 @@ class UploadFile |
|
|
if(!empty($rule['size'])){
|
|
|
if ($this->size > $rule['size']){
|
|
|
if(!$throw) return false;
|
|
|
app()->e(['verify_file.size',['',$this->name,$rule['size']]],600);
|
|
|
app()->e(['verify_file.size',[' ',$this->name,$rule['size']]],600);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|