|
@@ -100,7 +100,7 @@ class UploadFile |
|
@@ -100,7 +100,7 @@ class UploadFile |
100
|
$ext = explode('.',$name);
|
100
|
$ext = explode('.',$name);
|
101
|
$this->ext = end($ext);
|
101
|
$this->ext = end($ext);
|
102
|
|
102
|
|
103
|
- $this->savePath = PUBLIC_PATH.'/storage/';
|
103
|
+ $this->savePath = PUBLIC_PATH;
|
104
|
|
104
|
|
105
|
}
|
105
|
}
|
106
|
|
106
|
|
|
@@ -118,7 +118,7 @@ class UploadFile |
|
@@ -118,7 +118,7 @@ class UploadFile |
118
|
}
|
118
|
}
|
119
|
|
119
|
|
120
|
// 保存的文件
|
120
|
// 保存的文件
|
121
|
- $this->saveName = $name ? $name : md5_file($this->tempFile).'.'.$this->ext;
|
121
|
+ $this->saveName = '/storage/'.($name ? $name : md5_file($this->tempFile).'.'.$this->ext);
|
122
|
|
122
|
|
123
|
if($this->isUpload){
|
123
|
if($this->isUpload){
|
124
|
return move_uploaded_file($this->tempFile,$this->savePath.$this->saveName);
|
124
|
return move_uploaded_file($this->tempFile,$this->savePath.$this->saveName);
|
|
@@ -141,22 +141,19 @@ class UploadFile |
|
@@ -141,22 +141,19 @@ class UploadFile |
141
|
* @time 2023/4/18 10:55
|
141
|
* @time 2023/4/18 10:55
|
142
|
*/
|
142
|
*/
|
143
|
public function verify(array $rule,bool $throw = true){
|
143
|
public function verify(array $rule,bool $throw = true){
|
144
|
- $this->lastVerifyError = '';
|
|
|
145
|
// 后缀
|
144
|
// 后缀
|
146
|
if(!empty($rule['ext'])){
|
145
|
if(!empty($rule['ext'])){
|
147
|
- $rule['ext'] = is_string($rule['ext']) ? [$rule['ext']] : [];
|
|
|
148
|
if (!in_array($this->ext,$rule['ext'])){
|
146
|
if (!in_array($this->ext,$rule['ext'])){
|
149
|
if(!$throw) return false;
|
147
|
if(!$throw) return false;
|
150
|
- app()->e(['verify_file.ext',['',$this->name,implode('|',$rule['ext'])]],600);
|
148
|
+ app()->e(['verify_file.ext',[' ',$this->name,implode('|',$rule['ext'])]],600);
|
151
|
}
|
149
|
}
|
152
|
}
|
150
|
}
|
153
|
|
151
|
|
154
|
// 类型
|
152
|
// 类型
|
155
|
if(!empty($rule['mine'])){
|
153
|
if(!empty($rule['mine'])){
|
156
|
- $rule['mine'] = is_string($rule['mine']) ? [$rule['mine']] : [];
|
|
|
157
|
if (!in_array($this->mime,$rule['mine'])){
|
154
|
if (!in_array($this->mime,$rule['mine'])){
|
158
|
if(!$throw) return false;
|
155
|
if(!$throw) return false;
|
159
|
- app()->e(['verify_file.mine',['',$this->name,implode('|',$rule['mine'])]],600);
|
156
|
+ app()->e(['verify_file.mine',[' ',$this->name,implode('|',$rule['mine'])]],600);
|
160
|
}
|
157
|
}
|
161
|
}
|
158
|
}
|
162
|
|
159
|
|
|
@@ -164,9 +161,10 @@ class UploadFile |
|
@@ -164,9 +161,10 @@ class UploadFile |
164
|
if(!empty($rule['size'])){
|
161
|
if(!empty($rule['size'])){
|
165
|
if ($this->size > $rule['size']){
|
162
|
if ($this->size > $rule['size']){
|
166
|
if(!$throw) return false;
|
163
|
if(!$throw) return false;
|
167
|
- app()->e(['verify_file.size',['',$this->name,$rule['size']]],600);
|
164
|
+ app()->e(['verify_file.size',[' ',$this->name,$rule['size']]],600);
|
168
|
}
|
165
|
}
|
169
|
}
|
166
|
}
|
|
|
167
|
+ return true;
|
170
|
}
|
168
|
}
|
171
|
|
169
|
|
172
|
|
170
|
|