-
Notifications
You must be signed in to change notification settings - Fork 1
/
MY_Upload.php
45 lines (39 loc) · 1.1 KB
/
MY_Upload.php
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
<?php
class MY_Upload extends CI_Upload {
function is_allowed_filetype() {
if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types)) {
$this->set_error('upload_no_file_types');
return FALSE;
}
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe', 'eps');
foreach ($this->allowed_types as $val) {
$mime = $this->mimes_types(strtolower($val));
// Images get some additional checks
if (in_array(strtolower($val), $image_types)) {
if (strtolower($val) === 'eps') {
try {
$img = new Imagick($this->file_temp);
$geo = $img->getImageGeometry();
} catch (ImagickException $e) {
return false;
}
} else {
if (getimagesize($this->file_temp) === false) {
return false;
}
}
}
if (is_array($mime)) {
if (in_array($this->file_type, $mime, true)) {
return true;
}
} else {
if ($mime == $this->file_type) {
return true;
}
}
}
return false;
}
}
?>