-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImageUpload.class.php
More file actions
executable file
·82 lines (73 loc) · 1.74 KB
/
ImageUpload.class.php
File metadata and controls
executable file
·82 lines (73 loc) · 1.74 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Images upload
*
* requere FileUpload class
*/
class ImageUpload extends FileUpload{
private $iMaxWidth = 100;
private $iMaxHeight = 100;
private $iMinWidth = 100;
private $iMinHeight = 100;
/**
* @param Array $files
*/
public function __construct($files){
parent::__construct($files);
$this->setValidTypes(array('jpg','jpeg','png','gif'));
}
/**
* set available images sizes
*
* @param int $iMinWidth
* @param int $iMinHeight
* @param int $iMaxWidth
* @param int $iMaxHeight
*/
public function setSizes($iMinWidth, $iMinHeight, $iMaxWidth, $iMaxHeight ){
$this->iMinWidth = $iMinWidth;
$this->iMinHeight = $iMinHeight;
$this->iMaxWidth = $iMaxWidth;
$this->iMaxHeight = $iMaxHeight;
}
public function checkAllSizes(){
if (is_array($this->files) && !empty($this->files)){
$files = 0;
foreach ($this->files as $key => $item){
if (!empty($item['tmp_name'])){
if ( !$this->checkSizes($item['tmp_name'])){
return false;
}else {
$files++;
}
}
}
if ($files>0){
return true;
}
}
return false;
}
public function getSizes(){
return array(
'minWidth' => $this->iMinWidth,
'minHeight' => $this->iMinHeight,
'maxWidth' => $this->iMaxWidth,
'maxHeight' => $this->iMaxHeight
);
}
private function checkSizes($image_path){
$info = array();
$sizes = getimagesize($image_path,$info);
if ($sizes){
if ( $sizes[0]>=$this->iMinWidth && $sizes[0]<=$this->iMaxWidth
&& $sizes[1]>=$this->iMinHeight && $sizes[1]<=$this->iMaxHeight
){
return true;
}
}else {
return false;
}
}
}
?>