-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatephoto.php
57 lines (43 loc) · 1.48 KB
/
updatephoto.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
<!DOCTYPE html>
<html>
<head>
<title>ChatNode</title>
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<?php include ('session.php');?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" value="save" name="image" />
<?php
include ('includes/database.php');
if (!isset($_FILES['image']['tmp_name'])) {
echo "";
}else{
$file=$_FILES['image']['tmp_name'];
$image = $_FILES["image"] ["name"];
$image_name= addslashes($_FILES['image']['name']);
$size = $_FILES["image"] ["size"];
$error = $_FILES["image"] ["error"];
if ($error > 0){
die("Error uploading file! Code $error.");
}else{
if($size > 10000000) //conditions for the file
{
die("Format is not allowed or file size is too big!");
}
else
{
move_uploaded_file($_FILES["image"]["tmp_name"],"uploads/" . $_FILES["image"]["name"]);
$location="uploads/profile/" . $_FILES["image"]["name"];
$user=$_SESSION['id'];
$update=mysqli_query($conn, "UPDATE user SET profile_picture = '$location' WHERE user_id='$user'");
$update1=mysqli_query($conn, "UPDATE comments SET image = '$location' WHERE user_id='$user'");
}
header('location:home.php');
}
}
?>
</form>
</body>
</html>