Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../koneksi.php";
- $no = 1;
- $db = mysqli_query($conn, "SELECT * FROM tbl_user_permohonan");
- while($row = mysqli_fetch_array($db)){
- $potong = $row['file'];
- $fix_potong = substr($potong,22);
- ?>
- <tr>
- <td><?php echo $no++ ?></td>
- <td><?php echo $row['unit_cabang']; ?> </td>
- <td><?php echo $fix_potong ; ?> </td>
- <td><?php echo $row['tanggal']; ?> </td>
- <th>
- <!-- button download file -->
- <a href="download.php?filename=<?=$row['file'] ?>" type="button" class="btn btn-primary" >
- <i class="fas fa-fw fa-edit"></i> Download</a></th>
- </tr>
- ===============================================================================
- <?php
- include "../koneksi.php";
- if (isset($_GET['filename'])) {
- $filename = $_GET['filename'];
- $file = "../laporan-permohonan/".$_GET['filename'];
- if (file_exists($file)) {
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename='.basename($file));
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: private');
- header('Pragma: private');
- header('Content-Length: ' . filesize($file));
- ob_clean();
- flush();
- readfile($file);
- exit;
- } else {
- // $_SESSION['pesan'] = "Oops! File - $filename - not found ...";
- // header("location:laporanBulanan.php");
- echo "eroor";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement