mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进上传文件验证
This commit is contained in:
@@ -681,21 +681,17 @@ class Validate
|
||||
*/
|
||||
protected function fileExt($file, $rule)
|
||||
{
|
||||
if (!($file instanceof File)) {
|
||||
return false;
|
||||
}
|
||||
if (is_string($rule)) {
|
||||
$rule = explode(',', $rule);
|
||||
}
|
||||
if (is_array($file)) {
|
||||
foreach ($file as $item) {
|
||||
if (!$item->checkExt($rule)) {
|
||||
if (!($item instanceof File) || !$item->checkExt($rule)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
} elseif ($file instanceof File) {
|
||||
return $file->checkExt($rule);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,21 +704,17 @@ class Validate
|
||||
*/
|
||||
protected function fileMime($file, $rule)
|
||||
{
|
||||
if (!($file instanceof File)) {
|
||||
return false;
|
||||
}
|
||||
if (is_string($rule)) {
|
||||
$rule = explode(',', $rule);
|
||||
}
|
||||
if (is_array($file)) {
|
||||
foreach ($file as $item) {
|
||||
if (!$item->checkMime($rule)) {
|
||||
if (!($item instanceof File) || !$item->checkMime($rule)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
} elseif ($file instanceof File) {
|
||||
return $file->checkMime($rule);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,18 +727,17 @@ class Validate
|
||||
*/
|
||||
protected function fileSize($file, $rule)
|
||||
{
|
||||
if (!($file instanceof File)) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($file)) {
|
||||
foreach ($file as $item) {
|
||||
if (!$item->checkSize($rule)) {
|
||||
if (!($item instanceof File) || !$item->checkSize($rule)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
} elseif ($file instanceof File) {
|
||||
return $file->checkSize($rule);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user