chaoyu/app/validate/Upload.php

60 lines
1.5 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace app\validate;
use think\Validate;
use app\model\System;
use think\Lang;
class Upload extends Validate
{
protected $rule = [];
protected $message = [];
protected $system;
public function __construct()
{
$this->system = System::getSystem();
$this->lang = new Lang;
}
//验证图片上传
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]);
}
}