60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
<?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]);
 | 
						||
    }
 | 
						||
} |