-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimagetest.php
49 lines (46 loc) · 1.05 KB
/
imagetest.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<br/>
<input type="file" name="image">
<br/><br/>
<input type="submit" name="submit" value="Upload" />
</form>
<?php
if(isset($_POST['submit']))
{
if(getimagesize($_FILES['image']['tmp_name']) ==FALSE)
{
echo "Please select an image";
}
else
{
$image = addslashes($_FILES['image']['tmp_name']);
$name = addslashes($_FILES['image']['name']);
$image = file_get_contents($image);
$image=base64_encode($image);
}
}
function saveimage()
{
$con = mysql_connect("localhost","root","");
mysql_select_db("personal_details",$con);
$qry="insert into students(name,image) values ('$name','$image') where enroll_id = '12345' ";
$result = mysql_query($qry,$con);
if($result)
{
echo "<br/> Image uploaded";
}
else
{
echo "<br/> Image not Uploaded";
}
}
?>
</body>
</html>