-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
63 lines (42 loc) · 1.34 KB
/
function.php
File metadata and controls
63 lines (42 loc) · 1.34 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
<?php
session_start();
$error = [];
/**
* Check the main directory is exists or not.If is not will make directory .
* @param string $dir require
*/
function crdir(string $dir){
if (!is_dir($dir)) mkdir($dir);
}
/**
* Check the file's type is valid or not and very customizable.
* @param string $fileType Require
* @param array $validTypes Require
*/
function valid_type(string $fileType,array $validTypes){
global $error;
if (!in_array($fileType,$validTypes)) {
$message = 'Your File\'s type is ' . $fileType . ' but the files type must be (jpeg,png,jpg)';
array_push($error, $message);
}
}
/**
* Attempts to know is file's size valid.
* @param int|string $fileSize oRequire
* @param int $maximumSize Require
*/
function valid_size($fileSize, int $maximumSize){
$maxSize = $maximumSize;
global $error;
if ($fileSize > $maxSize) {
$message = 'The files size is too big';
array_push($error, $message);
}
}
function valid_scale($height,$width,$maxHeight,$maxWidth,$minHeight,$minWidth){
global $error;
if ($width > $maxWidth && $height > $maxHeight) {
$message = 'Your file scale should be within bigger than ('. $maxWidth.'x'. $maxHeight.') and lower than ('. $minWidth.'x'. $minHeight.')';
array_push($error, htmlspecialchars($message));
}
}