-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupload.php
130 lines (110 loc) · 2.37 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
<?php
session_start();
if(!isset($_SESSION['sess_user']) )
{
header("location:member.php");
}
else
{ }
if(isset($_POST['submit']))
{
if(getimagesize($_FILES['image']['tmp_name'])==FALSE)
{
echo " erroring ";
}
else
{
$image = $_FILES['image']['tmp_name'];
$image = addslashes(file_get_contents($image));
saveimage($image);
}
}
function saveimage($image)
{
$dbcon = mysqli_connect('localhost','root','','mydb') or die(mysql_error());
$qry="update login set img = '".$image."' where username ='".$_SESSION['sess_user']."'";
$result=mysqli_query($dbcon,$qry);
if($result)
{
echo " <br/>Image uploaded.";
header("location:member.php");
}
else
{
echo " error set ";
}
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<style>
body{
margin-top: 100px;
margin-bottom: 100px;
margin-right: 150px;
margin-left: 80px;
background-color: azure ;
color: palevioletred;
font-family: 'Nanum Gothic', sans-serif;
font-size: 20px;
}
h2 {
color: indigo;
font-family: 'Nanum Gothic', sans-serif;
font-size:50px;
position: absolute;
top: 0;
RIGHT: 0;
} h6
{
color: indigo;
font-family: 'Nanum Gothic', sans-serif;
font-size:16px;
}
input.b,.btn-group button{
border-radius: 1px;
border: none;
text-align: center;
font-size: 18px;
padding: 8px;
width: 110px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
align:center;
color: #800000
font-family: 'Nanum Gothic', sans-serif;
margin-left: 80px;
margin-top: 20px;
}
input.b,.btn-group button{
content: "";
clear: both;
display: table;
}
input.b,.btn-group button {
border-right: none;
}
input.b:hover,.btn-group button:hover {
background-color: #B0E0E6;
font-family: 'Nanum Gothic', sans-serif;
font-size: 16px;
}
.btn-group button
{
position: absolute;
top: 120;
right: 19;
}
</style>
<body>
<h2>Welcome, <?=$_SESSION['sess_user'];?>! </h2>
<h6>Image size should less than 50 KB </h6>
<form method="post" enctype="multipart/form-data">
<input type="file" name="image"/>
<input type="submit" name="submit" value="Upload"/>
</form>
</body>
</html>