extensiemime-check
Code (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
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
<?php
### Set extensions and mime-types (lowercase)
$extensions = array('jpeg', 'jpg', 'gif', 'png');
$mimetypes = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png');
### Function
function filecheck($file)
{
### Set extension and mime-type in function
global $extensions;
global $mimetypes;
### Get pathinfo
$pathinfo = pathinfo($file['name']);
### Make extension lowercase
$extension = strtolower($pathinfo['extension']);
### Make mime-type lowercase
$mimetype = strtolower($file['type']);
### Check entension and mime-type
if (in_array($extension, $extensions) AND in_array($mimetype, $mimetypes))
{
### Return TRUE
return true;
}
else
{
### Return FALSE
return false;
}
}
?>
### Set extensions and mime-types (lowercase)
$extensions = array('jpeg', 'jpg', 'gif', 'png');
$mimetypes = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png');
### Function
function filecheck($file)
{
### Set extension and mime-type in function
global $extensions;
global $mimetypes;
### Get pathinfo
$pathinfo = pathinfo($file['name']);
### Make extension lowercase
$extension = strtolower($pathinfo['extension']);
### Make mime-type lowercase
$mimetype = strtolower($file['type']);
### Check entension and mime-type
if (in_array($extension, $extensions) AND in_array($mimetype, $mimetypes))
{
### Return TRUE
return true;
}
else
{
### Return FALSE
return false;
}
}
?>