-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandleprofile.php
More file actions
64 lines (48 loc) · 1.81 KB
/
Copy pathhandleprofile.php
File metadata and controls
64 lines (48 loc) · 1.81 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
<?php
require 'partials/_dbconnect.php';
$pic_uploaded = 0;
if(isset($_REQUEST["submit"]))
{
$profile_username = $_REQUEST['profile-username'];
$user_id = $_REQUEST['uid'];
$profile_username = str_replace("<", "<", $profile_username);
$profile_username = str_replace(">", ">", $profile_username);
$profile_username = str_replace("'", "'", $profile_username);
$image = time().$_FILES["profile-pic-update"]['name'];
if(move_uploaded_file($_FILES['profile-pic-update']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/FP/img/'.$image))
{
$target_file = $_SERVER['DOCUMENT_ROOT'].'/FP/img/'.$image;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$picname = basename($_FILES['profile-pic-update']['name']);
$photo = time().$picname;
if($imageFileType != "jpg" && $imageFileType != "jpeg" && $imageFileType != "png")
{
echo '<script>alert("Please post image having jpg/jpeg/png type");</script>';
}
else if($_FILES["profile-pic-update"]["size"] > 20000000)
{
echo '<script>alert("Your Image size is too high");</script>';
}
else
{
$pic_uploaded = 1;
}
}
if($pic_uploaded == 1)
{
$update_query = mysqli_query($conn, "UPDATE `users` SET `username` = '$profile_username', `user_profile_pic` = '$photo' WHERE `users`.`user_id` = '$user_id'");
if($update_query > 0)
{
echo '
<script>
alert("Profile updated");
window.location = "profile.php";
</script>';
}
}
else
{
echo '<script>alert("Failed to update profile");</script>';
}
}
?>