Coding Download
Coding Download
Coding Download
Table = file
1. index.php
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--Script CSS-->
<link type="text/css"
href='https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css' rel='stylesheet'>
<body>
<div class="container">
<div class="container-fluid">
<div class="navbar-header">
</div>
</div>
</nav>
<br />
<br />
</form>
<div class="form-group">
<thead>
<tr>
<th>No</th>
<th>File Name</th>
<th>Action</th>
</tr>
</thead>
<tbody class="alert-success">
<?php
require 'config.php';
while($fetch = $row->fetch_array()){
?>
<tr>
<?php
?>
</tr>
<?php
?>
</tbody>
</table>
</div>
<!--Script Javascript-->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.colVis.min.js"></script>
<script>
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'colvis'
} );
} );
</script>
</body>
</html>
2. config.php
<?php
if($conn->connect_error){
die("Fatal Error: Can't connect to database: ". $conn->connect_error);
?>
3. upload.php
<?php
require_once 'config.php';
if(ISSET($_POST['submit'])){
if($_FILES['upload']['name'] != "") {
$file = $_FILES['upload'];
$file_name = $file['name'];
$file_temp = $file['tmp_name'];
$path = "files/".$file_name;
move_uploaded_file($file_temp, $path);
header("location:index.php");
}else{
?>
4. download.php
<?php
if(ISSET($_REQUEST['file'])){
$file = $_REQUEST['file'];
//header("Cache-Control: public");
header("Content-Type: application/octet-stream;");
//header("Content-Transfer-Encoding: binary");
readfile("files/".$file);
?>