ImageModel.php
686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace App\Model\Oss;
use Illuminate\Database\Eloquent\Model;
class ImageModel
{
protected $allowExt = array('jpg', 'jpeg', 'png', 'gif', 'bmp');
protected $allowMaxSize = 2*1024*1024; // 2M
/**
* 检查图片后缀名
* @param [String] $ext [图片后缀]
* @return [Boolen]
*/
public function checkImageExt($ext)
{
if (in_array(strtolower($ext), $this->allowExt)) {
return true;
} else {
return false;
}
}
/**
* 检查图片大小
* @param [Integer] $size [图片大小]
* @return [Boolen]
*/
public function checkImageSize($size)
{
if ($size > $this->allowMaxSize) {
return false;
} else {
return true;
}
}
}