-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadLogoTool.php
More file actions
65 lines (49 loc) · 1.98 KB
/
uploadLogoTool.php
File metadata and controls
65 lines (49 loc) · 1.98 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
<?php
require "../phplib/genlibraries.php";
//if($_POST){
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
/*var_dump($_REQUEST);
var_dump($_FILES['file']['size']);
var_dump(getimagesize($_FILES['file']['tmp_name']));*/
$toolid = $_REQUEST["toolid"];
$result = $GLOBALS['toolsDevMetaCol']->findOne(array("_id" => $toolid));
$path = __DIR__ . "/../files/".$result["user_id"]."/.dev/".$toolid."/logo/";
if(!file_exists($path)) mkdir($path);
$valid_formats = array("png");
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$tmp_name = $_FILES['file']['tmp_name'];
$width = getimagesize($tmp_name)[0];
$height = getimagesize($tmp_name)[1];
if(strlen($name)) {
list($txt, $ext) = explode(".", strtolower($name));
if(in_array($ext,$valid_formats)) {
if($size<(1024*1024*3)) { // Image size max 3 MB
if($width == 600 && $height == 600) {
$actual_image_name = "logo.".$ext;
if(move_uploaded_file($tmp_name, $path.$actual_image_name)) {
$_SESSION['errorData']['Info'][] = "Logo successfully uploaded.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
} else {
$_SESSION['errorData']['Error'][] = "Error uploading files, please try again.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
} else {
$_SESSION['errorData']['Error'][] = "Image size must be <strong>600x600</strong> pixels.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
} else {
$_SESSION['errorData']['Error'][] = "The maximum allowed size for the image mus be <strong>3MB</strong>.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
} else {
$_SESSION['errorData']['Error'][] = "Only <strong>PNG</strong> images allowed.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
} else {
$_SESSION['errorData']['Error'][] = "Incorrect file name, please try again.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
}else{
redirect($GLOBALS['URL']);
}