58 lines
1.4 KiB
PHP
Executable File
58 lines
1.4 KiB
PHP
Executable File
<?php
|
||
namespace app\validate;
|
||
|
||
use think\Validate;
|
||
use app\model\System;
|
||
|
||
class Upload extends Validate
|
||
{
|
||
protected $rule = [];
|
||
protected $message = [];
|
||
protected $system;
|
||
public function __construct()
|
||
{
|
||
$this->system = System::getSystem();
|
||
}
|
||
|
||
//验证图片上传
|
||
public function checkImage($image)
|
||
{
|
||
$ext = str_replace(',', ',', $this->system['img_type']);
|
||
$size = $this->system['img_size'] * 1024 * 1024;
|
||
$this->rule = [
|
||
'image' => [
|
||
'fileExt' => $ext,
|
||
'fileSize' => (int)$size
|
||
]
|
||
];
|
||
return $this->check(['image' => $image]);
|
||
}
|
||
|
||
//验证视频上传
|
||
public function checkVideo($video)
|
||
{
|
||
$ext = str_replace(',', ',', $this->system['video_type']);
|
||
$size = $this->system['video_size'] * 1024 * 1024;
|
||
$this->rule = [
|
||
'video' => [
|
||
'fileExt' => $ext,
|
||
'fileSize' => (int)$size
|
||
]
|
||
];
|
||
return $this->check(['video' => $video]);
|
||
}
|
||
|
||
//验证文件上传
|
||
public function checkFile($file)
|
||
{
|
||
$ext = str_replace(',', ',', $this->system['file_type']);
|
||
$size = $this->system['file_size'] * 1024 * 1024;
|
||
$this->rule = [
|
||
'file' => [
|
||
'fileExt' => $ext,
|
||
'fileSize' => (int)$size
|
||
]
|
||
];
|
||
return $this->check(['file' => $file]);
|
||
}
|
||
} |