-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangepp.php
109 lines (94 loc) · 3.19 KB
/
changepp.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
<?php require_once("./controller/deps.php"); ?>
<?php header_section("Dashboard | Edit Profile Picture"); ?>
<?php
if ($_SESSION['login'] == false) {
header("Location: login.php");
exit();
}
$errors_message = [];
$success_message = "";
if (isset($_GET['success'])) {
if ($_GET['success'] == "true") {
// var_dump($_GET);
$success_message = "Successfully Uploaded";
}
}
if (isset($_GET['errors'])) {
$errors_code = explode(",", $_GET['errors']);
foreach ($errors_code as $error) {
if ($error == "choosefile") {
array_push($errors_message, "Select an Image");
}
if ($error == "emptyid") {
array_push($errors_message, "Empty ID");
}
if ($error == "fileexists") {
array_push($errors_message, "File is already exists");
}
if ($error == "bigfile") {
array_push($errors_message, "File size is greater than 40mb");
}
if ($error == "notfiletype") {
array_push($errors_message, "File type is invalid. only (jpg, jpeg and png) file type supported");
}
}
}
?>
<main class="clearfix">
<?php if (count($errors_message)) : ?>
<div class="errors-list">
<table>
<tbody>
<?php foreach ($errors_message as $err_msg) : ?>
<tr>
<td>!! <?php echo $err_msg; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
<?php if (!empty($success_message)) : ?>
<div class="success">
<table>
<tbody>
<tr>
<td><?php echo $success_message; ?></td>
</tr>
</tbody>
</table>
</div>
<?php endif; ?>
<div class="file-upload">
<form action="./controller/changepp.php" method="post" enctype="multipart/form-data">
<?php if (isset($_SESSION['id']) && !empty($_SESSION['id'])) : ?>
<input type="hidden" name="id" value="<?php echo $_SESSION['id']; ?>">
<?php endif; ?>
<?php if (isset($_SESSION['type']) && !empty($_SESSION['type'])) : ?>
<input type="hidden" name="type" value="<?php echo $_SESSION['type']; ?>">
<?php endif; ?>
<table>
<tbody>
<tr>
<td><input class="inp" id="file" type="file" name="profilepicfile"></td>
</tr>
<tr>
<td>
<button class="btn" id="submit" type="submit" name="upload">Upload</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="file-info">
<table>
<tbody>
<tr>
<td><img src="<?php echo isset($_SESSION['purl']) && !empty($_SESSION['purl']) ? $_SESSION['purl'] : "./images/defaultprofile.png" ?>" alt="Profile Picture"></td>
</tr>
</tbody>
</table>
</div>
</main>
<?php footer_section(); ?>