-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocuments.php
More file actions
209 lines (194 loc) · 7.42 KB
/
Copy pathdocuments.php
File metadata and controls
209 lines (194 loc) · 7.42 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
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
198
199
200
201
202
203
204
205
206
207
208
209
<?php
session_start();
if (isset( $_SESSION['stid'])){
include ("dbcon.php");
if(isset($_POST['title']))
{
$_SESSION['matric'] = $_SESSION['stid'];
//The code to uploade images.
if((($_FILES["docpath"]["type"] == "image/gif")
||($_FILES["docpath"]["type"] == "image/jpeg")
||($_FILES["docpath"]["type"] == "image/pjpeg")
||($_FILES["docpath"]["type"] == "application/pdf")
||($_FILES["docpath"]["type"] == "application/doc")
||($_FILES["docpath"]["type"] == "appication/docx")
||($_FILES["docpath"]["type"] == "image/png"))
&&($_FILES["docpath"]["size"] < 500000))
{
if ($_FILES["docpath"]["error"] > 0)
{
echo "Return code: ". $_FILE["docpath"]["error"] . "<br/>";
}
else
{
if (file_exists("edozzier/stdoc/".$_SESSION['matric'] . $_FILES["docpath"]["name"]))
{
unlink("/edozzier/stdoc/".$_SESSION['matric'].$_FILES["docpath"]["name"]);
$path ="stdoc/".$_SESSION['matric'].$_FILES["docpath"]["name"];
move_uploaded_file($_FILES["docpath"]["tmp_name"],"../edozzier/".$path);
}
else
{
$path ="stdoc/".$_SESSION['matric'].$_FILES["docpath"]["name"];
move_uploaded_file($_FILES["docpath"]["tmp_name"],"../edozzier/".$path);
}
}
}
else
{
$message = "file upload failed";
}
//end of upload program
$d = date('Y-m-d');
mysqli_query($con,"insert into std_doc_tb (doc,title,description,date_uploaded,student_id) values ('$path','$_POST[title]','$_POST[description]','$d',$_SESSION[matric])");
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Student Profile | NBTS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<!-- font CSS -->
<link rel="icon" href="favicon.ico" type="image/x-icon" >
<!-- font-awesome icons -->
<link href="css/font-awesome.css" rel="stylesheet">
<!-- //font-awesome icons -->
<!-- chart -->
<script src="js/Chart.js"></script>
<!-- //chart -->
<!-- js-->
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/modernizr.custom.js"></script>
<!--webfonts-->
<link href='//fonts.googleapis.com/css?family=Roboto+Condensed:400,300,300italic,400italic,700,700italic' rel='stylesheet' type='text/css'>
<!--//webfonts-->
<!--animate-->
<link href="css/animate.css" rel="stylesheet" type="text/css" media="all">
<script src="js/wow.min.js"></script>
<script>
new WOW().init();
</script>
<!--//end-animate-->
<!-- Metis Menu -->
<script src="js/metisMenu.min.js"></script>
<script src="js/custom.js"></script>
<link href="css/custom.css" rel="stylesheet">
<!--//Metis Menu -->
</head>
<body class="cbp-spmenu-push">
<div class="main-content" style="padding:2%;">
<div class="panel panel-widget">
<div class="tables">
<h4>Your Documents</h4>
<table class="table"> <thead> <tr> <th>#</th> <th>Title</th> <th>Description</th><th>Date Uploaded</th> </tr> </thead> <tbody>
<?php
$seldoc = mysqli_query($con,"SELECT * FROM `std_doc_tb` where student_id =".$_SESSION['stid']);
$n = 1;
while($doc = mysqli_fetch_array($seldoc))
{
$p = "edozzier/".$doc['doc'];
$title = $doc['title'];
$desc = $doc['description'];
$d = $doc['date_uploaded'];
echo "
<tr class='active'> <th scope='row'>$n</th> <td><a href='$p' target='_blank'> $title</a></td> <td>$desc</td><th>$d</th> </tr>
";
$n++;
}
?>
</tbody> </table>
</div>
</div>
<div class="progressbar-heading grids-heading">
</div>
<div class="panel panel-widget">
<div class="block-page">
<div class="panel panel-widget">
<div class="validation-grids validation-grids-right">
<div class="widget-shadow login-form-shadow" data-example-id="basic-forms">
<div class="input-info">
<h3>Upload a Document :</h3>
</div>
<div class="form-body form-body-info">
<form data-toggle="validator" novalidate action="documents.php" method="post" enctype="multipart/form-data">
<div class="form-group has-feedback">
<input type="text" class="form-control" id="inputEmail" name="title" placeholder="Title" required>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" id="inputEmail" placeholder="Description" name="description" required>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-feedback">
<input type="file" class="form-control" id="inputEmail" name="docpath" required>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group">
<button type="submit" style="background:green; width:100%;" class="btn btn-success">Upload</button>
</div>
<div class="clearfix"> </div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--//grids-->
</div>
</div>
<!-- Classie -->
<script src="js/classie.js"></script>
<script>
var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
showLeftPush = document.getElementById( 'showLeftPush' ),
body = document.body;
showLeftPush.onclick = function() {
classie.toggle( this, 'active' );
classie.toggle( body, 'cbp-spmenu-push-toright' );
classie.toggle( menuLeft, 'cbp-spmenu-open' );
disableOther( 'showLeftPush' );
};
function disableOther( button ) {
if( button !== 'showLeftPush' ) {
classie.toggle( showLeftPush, 'disabled' );
}
}
</script>
<!-- Bootstrap Core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/dev-loaders.js"></script>
<script type="text/javascript" src="js/dev-layout-default.js"></script>
<script type="text/javascript" src="js/jquery.marquee.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery.jqcandlestick.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jqcandlestick.css" />
<!--max-plugin-->
<script type="text/javascript" src="js/plugins.js"></script>
<!--//max-plugin-->
<!--scrolling js-->
<script src="js/jquery.nicescroll.js"></script>
<script src="js/scripts.js"></script>
<!--//scrolling js-->
</body>
</html>
<?php
}
else{
echo "
<script>
alert ('Access Denied');
alert ('You need to Login First');
window.location='../studentlogin.php';
</script>
";
}
?>