-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpload.php
57 lines (50 loc) · 1.6 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
<?php
/**
* Created by PhpStorm.
* User: Ochieng_Derrick
* Date: 2/23/2018
* Time: 11:28 AM
*/
$msg = "";
if (isset($_POST['upload'])){
//path to store the uploaded images
$target = "C:/WampServer/wamp64/www/Gallery/img/".basename($_FILES['image']['name']);
$db = mysqli_connect("localhost", "root", "", "photos");
$image = $_FILES['image']['name'];
$text = $_POST['text'];
$sql = "INSERT INTO images (image, text) VALUES ('$image', '$text')";
mysqli_query($db, $sql);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)){
$msg = "Image uploaded Successfully";
}else{
$msg = "Failed to Upload Image";
}
}
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="plugins/bootstrap/css/bootstrap.css" />
</head>
<body>
<div class="container-fluid">
<div class="col-lg-4 col-md-5 col-sm-8 col-xs-10" style="margin: 150px auto; padding: 10px;">
<form method="post" action="" enctype="multipart/form-data">
<?php
echo $msg;
?>
<input type="hidden" name="size" value="1000000">
<div class="text-center" style="margin: 10px;">
<input type="file" name="image">
</div>
<div class="text-center" style="margin: 10px;">
<textarea name="text" cols="40" rows="4" placeholder="Say Something about this pic"></textarea>
</div>
<div class="text-center" style="margin: 10px;">
<button type="submit" class="btn btn-outline-primary" name="upload">Upload</button>
</div>
</form>
</div>
</div>
</body>
</html>