-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
188 lines (172 loc) · 4.87 KB
/
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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
require 'config.php';
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style media="screen">
#modalUpload{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
z-index: 1;
/* display: flex; */
display: flex;
justify-content: center;
align-items: center;
}
.modal{
background-color: rgba(230,236,240,0.8);
padding: 10px 0 20px 0;
width: 100%;
height: 100%;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
}
.top-form{
display: flex;
justify-content: flex-end;
}
.top-form .close-modal{
cursor: pointer;
padding: 0 20px;
font-size: 20px;
}
.login-form{
width: 100%;
}
.login-form h2{
letter-spacing: 1px;
margin-top: 10px;
margin-bottom: 30px;
}
.login-form form input, .login-form form select{
width: 75%;
margin-bottom: 20px;
padding: 12px 12px;
box-sizing: border-box;
border: 1px solid #d0d5d8;
border-radius: 3px;
}
.login-form form button{
padding: 12px 0px;
width: 75%;
background-color: #5dca88;
border: 0;
border-radius: 3px;
color: white;
margin: 10px auto;
cursor: pointer;
}
.btn-warning{
position: relative;
padding: 11px 16px;
font-size: 15px;
line-height: 1.5;
border-radius: 3px;
color: #fff;
background-color: #ffc100!important;
border: 0;
transition: 0.2s;
overflow: hidden; \\ L
}
.btn-warning input[type = "file"]{
cursor: pointer;
position: absolute;
left: 0%;
top: 0%;
transform: scale(3);
opacity: 0;
}
.btn-warning:hover{
background-color: #d9a400!important;
}
.mosque{
height: 80vw;
width: 80vw;
z-index:0;
filter: blur(2px);
}
.bottomcenter{
z-index: 1;
position: fixed;
left: 50%;
top:50%;
transform: translate(-50%, -50%);
margin: auto;
}
</style>
<div class="bottomcenter"><img src="mosque.png" class="mosque"></img></div>
<div id="modalUpload">
<div class="modal">
<div class="top-form">
</div>
<div class = "login-form">
<h1>Upload Kartu</h1>
<form action="" method = "post" spellcheck = "false" autocomplete="off" enctype="multipart/form-data">
<input class="form-control" type="email" placeholder="Email" required name = "email">
<input class="form-control" type="text" placeholder="Nama Kartu" required name = "imageName">
<div class="upload" style = "margin-top: -10px;">
<button type = "button" class = "btn-warning">
<i class = "fa fa-upload"></i> Upload Kartu
<input type="file" name="image" accept=".jpg, .jpeg, .png" required>
</button>
</div>
<button type = "submit" name = "submitimage" class = "submit-btn">Submit</button>
</form>
</div>
</div>
</div>
<?php
if(isset($_POST["submitimage"])){
$email = $_POST["email"];
$imageName = $_POST["imageName"];
if($_FILES["image"]["error"] == 4){
echo
"<script> alert('Image Does Not Exist'); </script>"
;
}
else{
$fileName = $_FILES["image"]["name"];
$fileSize = $_FILES["image"]["size"];
$tmpName = $_FILES["image"]["tmp_name"];
$validImageExtension = ['jpg', 'jpeg', 'png'];
$imageExtension = explode('.', $fileName);
$imageExtension = strtolower(end($imageExtension));
if ( !in_array($imageExtension, $validImageExtension) ){
echo
"
<script>
alert('Invalid Image Extension');
</script>
";
exit;
}
else if($fileSize > 1000000){
echo
"
<script>
alert('Image Size Is Too Large');
</script>
";
exit;
}
else{
$newImageName = $imageName . " - " . date("Y.m.d") . " - " . date("h.i.sa");
$newImageName .= '.' . $imageExtension;
$query = "INSERT INTO card VALUES(NULL, '$email', '$imageName', '$newImageName', 0)";
mysqli_query($con, $query);
move_uploaded_file($tmpName, "usersUpload/$newImageName");
echo
"
<script>
alert('Successfully Added');
document.location.href = 'upload.php?=';
</script>
";
}
}
}