-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaterials_upload.php
99 lines (85 loc) · 2.54 KB
/
materials_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
<?php
include('db.php');
session_start();
if (isset($_POST['upload'])) {
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file_tem_Loc = $_FILES['file']['tmp_name'];
$file_store = "uploads/".$file_name;
$fileextension = (explode('.',$file_name));
$fileextension = strtolower(end($fileextension));
$uploadPath = "./uploads/";
$extensions = array("pdf");
$name = $_POST['name'];
$subject=$_POST['name1'];
$staff = $_SESSION['staff'];
if (! in_array($fileextension,$extensions)) {
$err =1;
}
else if ($file_size > 200000000) {
$err=2;
}
else {
$didUpload=move_uploaded_file($_FILES["file"]["tmp_name"], $uploadPath.$subject.'_'.$staff.'_'.$name.'.pdf');
if ($didUpload) {
$err=0;
$query="INSERT INTO `materials` values('$subject','$name','$staff')";
if(!mysqli_query($con,$query))
{
$err=4;
}
else {
$err=0;
}
//echo "DONE";
} else {
$err=3;
}
}
}
else {
//echo "NOT THERE";
}
if(isset($_GET))
{
extract($_GET);
}
?>
<html>
<head>
<link rel = "stylesheet " type = "text/css" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel = "stylesheet" type = "text/css" href = "style.css">
</head>
<body style="background-image:url('./back.jpg'); background-repeat: no-repeat; background-position: center; background-attachment: fixed; background-size:cover;">
<div style = "padding-top: 10%; ">
<div class = "ml-auto mr-auto col-md-3 card" align = "left">
<br>
<?php
if(isset($err))
{
if( $err == 1){
echo "Only .jpg is supported!";
}
else if( $err == 2){
echo "File size exceeded!";
}
else if( $err > 2){
echo "File not uploaded";
}
else {
echo "File uploaded!";
}
}
?>
<br>
<form action="" method="POST" enctype="multipart/form-data">
<input type = "file" name = "file" class = "form-control" required placeholder ="Material" ><br><br>
<input type="mediumtext" name="name1" placeholder="Subject" /><br><br>
<input type="mediumtext" name="name" placeholder="Topic" /><br><br>
<input type="submit" name = "upload" class="btn btn-success" value = "Upload"/>
</form>
</div>
</div>
</body>
</html>