-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload.php
More file actions
126 lines (91 loc) · 3.08 KB
/
upload.php
File metadata and controls
126 lines (91 loc) · 3.08 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
<?php
if(isset($_POST['plog'])){
session_destroy();
header("location:signin.php");
}
?>
<?php
$conn = mysqli_connect('localhost','root','','example');
if(isset($_POST['submit'])){
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$path = "files/".$fileName;
$query = "INSERT INTO filedownload(filename) VALUES ('$fileName')";
$run = mysqli_query($conn,$query);
if($run){
move_uploaded_file($fileTmpName,$path);
}
else{
echo "error".mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>upload</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body style="background-color:#0C78CC ;">
<nav class="navbar " style="background-color: #2397f6">
<div class="container-fluid">
<h1 class="navbar-brand text-white fs-3 fw-bold">
<img src="photos/menu.png" class="navbar-brand" alt="">
CSE-326(Section-A)</h1>
<ul class=" nav">
<li class="nav-item">
<form action="" method="POST">
<a href="index.php" class="me-2"><img src="photos/home.png" class="logo" alt=""></a>
<a href="perform.php"><img src="photos/arrow (2).png" class="logo" alt=""></a>
<button class="btn " type="submit" name="plog"><img src="photos/check-out.png" alt=""></button>
</form>
</li>
<li class="nav-item mt-2"> <p class="text-light">
<img src="photos/user (5).png" alt="">
<?php
session_start();
echo $_SESSION['name'] ;
?>
</p></li>
</ul>
</div>
</nav>
<div class="container border bg-light rounded-3 mt-3" style="height: 620px;">
<div class="card-header bg-primary text-center mt-2">
<h1 class="text-light fw-bold ">Metarial Upload & Download</h1>
</div>
<form action="upload.php" method="post" enctype="multipart/form-data" class="d-flex justify-content-center">
<div class="input-group w-50 m-2 ">
<input type="file" name="file" class="btn btn-outline-primary form-control" >
<button type="submit" name="submit" class="btn btn-outline-primary"> Upload</button>
</div>
</form>
<div class="d-flex justify-content-center">
<table class="table table-bordered table-striped " style="width: 65%;">
<thead>
<tr>
<th>Name</th>
<th>Matarials</th>
</tr>
</thead>
<tbody>
<?php
$query2 = "SELECT * FROM filedownload ";
$run2 = mysqli_query($conn,$query2);
while($rows = mysqli_fetch_assoc($run2)){
echo'<tr>
<td>' .$rows['filename']. '</td>
<td>' ?>
<a class='text-primary' href="download.php?file=<?php echo $rows['filename'] ?>">Download</a><br>
<?php '</td>
</tr>';
}
?>
</tbody>
</table>
</div>
</div>
<script src="js/bootstrap.bundle.min.js"></script>
</body>
</html>