-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore_image.php
More file actions
42 lines (40 loc) · 1.13 KB
/
Copy pathstore_image.php
File metadata and controls
42 lines (40 loc) · 1.13 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
<?php
if($_SERVER['REQUEST_METHOD']=="POST")
{
if(isset($_POST['name']) && isset($_FILES['image']))
{
require 'connect_database.php';
echo $_POST['name'];
$image = $_FILES['image']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
$query =("INSERT into images (image, created) VALUES ('$imgContent', NOW())");
$res=mysqli_query($connection,$query);
if($res)
{
echo "success";
}
else
{
echo "error";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="<?php htmlspecialchars($_SERVER['PHP_SELF']);?>" method="Post" enctype="multipart/form-data">
IMAGE NAME:
<input type="text" name="name"><br>
Image file:
<input type="file" name="image"><br>
<input type="submit" value="click">
</form>
</body>
</html>