-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
37 lines (29 loc) · 1013 Bytes
/
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
<?php
if (isset($_POST["submit"])) {
$check = getimagesize($_FILES["image"]["tmp_name"]);
if ($check !== false) {
$image = $_FILES['image']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
$name = $_POST["name"];
$dbHost = 'localhost:3306';
$dbUsername = 'root';
$dbPassword = 'sankeeth72';
$dbName = 'test';
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
$insert = $db->query("INSERT into images (image,name) VALUES ('$imgContent','$name')");
if ($insert) {
echo "File uploaded successfully.";
} else {
echo "File upload failed, please try again.";
}
} else {
echo "Please select an image file to upload.";
}
}
?>
<!--<html>
<p><img src="view.php?image=<?php print $s; ?>" height="100" width="100" /></p>
</html>-->