-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadpage.php
197 lines (153 loc) · 5.33 KB
/
uploadpage.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!doctype html>
<html>
<head>
<title> </title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="jquery-3.3.1.min.js"></script>
<style>
html,body{
font-family: Verdana, sans-serif;
}
.bg{
background-image: url("img/pink.jpg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.form1{
width: 900px;
height:1510px;
border-radius:20px;
margin-left: auto;
margin-right: auto;
padding: 30px;
margin-bottom:20px;
background-color: #ffffff;
overflow: scroll;
}
footer
{
position: relative;
bottom: 0px;
left: 30%;
height: 5%;
float: left;
font-size: 16px;
}
.searche{
margin-top: 8px;
width: 70px;
height:38px;
margin-left: -5px;
border-radius: 10px;
}
.search_field{
margin-top: 8px;
border-radius: 10px;
height: 38px;
}
li{
font-size: 17px;
}
object
{
border-radius: 10px;
color: black;
width: 820px;
height:450px;
}
</style>
</head>
<body class="bg">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Sweets Recipes</a>
</div>
<ul class="nav navbar-nav">
<li ><a href="index.php" style="font-size: 17px;">Home</a></li>
<li><a href="Recipes.php" style="font-size: 17px;">Recipes</a></li>
<li><a href="about.php" style="font-size: 17px;">About Us</a></li>
<li><a href="contact.php" style="font-size: 17px;" >Contact Us</a></li>
<li> <form action="search.php" method='GET'>
<input class="search_field" type="text" placeholder="Search.." name="search">
<i ><input class="searche" type="submit" name="submit"></i>
</form></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="welcome.php" style="font-size: 17px;"><span class="glyphicon glyphicon-user"></span>Profile</a></li>
<li ><a href="logout.php" style="font-size: 17px;"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</nav>
<div class="form1">
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" class="btn btn-primary" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
<?php
$dbname="sweet website";
$servername="localhost";
$password="";
$dbuser="root";
$conn= mysqli_connect($servername,$dbuser,$password,$dbname);
$query = "SELECT * FROM upload ORDER BY id DESC";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($result))
{
$title = $row ['name'];
$url = $row ['content'];
$usern= $row['user_uploaded'];
echo " <p> Name: ".$title." </p>";
echo ' <tr>
<object data="data:application/pdf;base64,'.base64_encode($row['content'] ).'" type="application/pdf"></object>';
echo "<br> Uploaded By User:".$usern."";
echo "<hr>
</tr>";
}
?>
</table>
<a href="#top "id="panel">Top</a>
</form>
</div>
<footer>
<p><small>Copyright © 2018 <a href="index.html">Sweets Website</a> All rights reserved | Website By <a target="_blank" href="[email protected]">Sarah Alm</a></small></p>
</footer>
<script>
$(document).ready(function(){
$('#upload').click(function(){
var file_name = $('#userfile').val();
if(file_name == '')
{
alert("Please Select File");
return false;
}
else
{
var extension = $('#userfile').val().split('.').pop().toLowerCase();
if(jQuery.inArray(extension, ['pdf']) == -1)
{
alert('Invalid Document File, Please enter a PDF file Type');
$('#userfile').val('');
return false;
}
}
});
});
</script>
</body>
</html>