-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathu-upload.php
151 lines (103 loc) · 3.75 KB
/
u-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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
include_once("checkUserLoginStatus.php");
if(!$user_ok) {
header("location: $siteAddress/loginpage.php");
exit();
}
if(isset($_FILES['filefield']['tmp_name'])){
$name=$_FILES['filefield']['name'];
$name = preg_replace('#[ ]#i', '_', $name);
$title = $_POST["title"];
$imgcategory =$_POST["imgcategory"];
$description = $_POST["description"];
if ($_FILES['filefield']['tmp_name'] != "") {
// $newname = "give_some_unique_name.jpg";
$query = "INSERT INTO images(name,userName,imageCategory,description,image,date_time) values('$title','$log_username','$imgcategory','$description','upload/$name',now())";
mysqli_query($connect_db,$query) or die(mysqli_error($connect_db));
move_uploaded_file($_FILES['filefield']['tmp_name'], "upload/$name");
header("location: $siteAddress/thank-you.php");
}
exit();
}
?>
<!doctype html>
<html lang="en">
<head>
<title>Upload image</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!--styles css-->
<?php include_once "styles.php"; ?>
<!--styles css-->
</head>
<body>
<!--navbar-->
<?php include_once "header.php"; ?>
<br><br>
<div class="container-fluid m-0 p-0" >
<br>
<h1 class= "text-center">Upload Your Image</h1><br>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8 container card" style="background-image: url('images/upload.jpeg'); width:100%;height:auto;">
<br>
<div class="title">
<h3 class="text-center">Please Fill In The Details Below</h3>
<hr>
<form class="text-center" method="post" action="u-upload.php" enctype='multipart/form-data' onsubmit="return checkCheckBox(this)">
<label>Enter Image Name </label><br>
<input id="title" type="text" name="title" size="30" value="" class="w-50 stsf-b" ><br><br>
<label>Write Image Description</label><br>
<input id="description" type="text" name="description" size="70" ><br><br>
<label>Select Image Category</label><br>
<select name="imgcategory" id="imgcategory" class="w-50 stsf-b" >
<option value="Education">Education</option>
<option value="Technology">Technology</option>
<option value="Architecture">Architecture</option>
<option value="Nature">Nature</option>
<option value="Interior">Interior</option>
<option value="Adventure">Adventure</option>
<option value="Monuments">Monuments</option>
<option value="Photgraphy">Photgraphy</option>
</select><br><br>
<label>Write additional tags</label><br>
<input type="text" name="imageName" value="" class="w-50 stsf-b" placeholder="Write tags here..." ><br><br>
<label class="btn btn-info " for="upload-file-selector">
<label>Select Image To Upload</label>
<input type='file' id="filefield" name='filefield' class="form-control"/>
</label><br>
<br>
You can upload photos that are .JPEG, .JPG, or .PNG.<br>Max file size 25mb <br>
<!-- <label><input type="checkbox" value="">  I Agree <a href="#">Terms and Conditions</a></label><br><br>
-->
<b>By submitting, I agree that all info entered was done accurately & truthfully.</b><br />
<input type="checkbox" value="0" name="agree"/>I Agree <a href="#">Terms and Conditions</a>
<br>
<a href="http://localhost:8080/sellmyclick/thank-you.php"><button>submit</button></a>
<!-- <input type='submit' value='Save name' name='but_upload' id="submitbtn" ></a>
-->
<br><br>
</form>
</div>
</div>
<div class="col-md-2"></div>
</div>
</div>
<br><br>
<!--footer-->
<?php include_once "footer.php"; ?>
<!-- end of footer-->
<?php include_once "script.php"; ?>
<script>
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert('Please check the box to continue.');
return false;
}else
return true;
}
</script>
</body>
</html>