Advertisement
Guest User

Untitled

a guest
Sep 4th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1.  
  2. <?php
  3. include "../koneksi.php";
  4. $no = 1;
  5.  
  6. $db = mysqli_query($conn, "SELECT * FROM tbl_user_permohonan");
  7. while($row = mysqli_fetch_array($db)){
  8. $potong = $row['file'];
  9. $fix_potong = substr($potong,22);
  10. ?>
  11.  
  12. <tr>
  13. <td><?php echo $no++ ?></td>
  14. <td><?php echo $row['unit_cabang']; ?> </td>
  15. <td><?php echo $fix_potong ; ?> </td>
  16. <td><?php echo $row['tanggal']; ?> </td>
  17. <th>
  18.  
  19. <!-- button download file -->
  20. <a href="download.php?filename=<?=$row['file'] ?>" type="button" class="btn btn-primary" >
  21. <i class="fas fa-fw fa-edit"></i> Download</a></th>
  22. </tr>
  23.  
  24. ===============================================================================
  25.  
  26. <?php
  27.  
  28. include "../koneksi.php";
  29.  
  30. if (isset($_GET['filename'])) {
  31.  
  32. $filename = $_GET['filename'];
  33.  
  34. $file = "../laporan-permohonan/".$_GET['filename'];
  35.  
  36. if (file_exists($file)) {
  37. header('Content-Description: File Transfer');
  38. header('Content-Type: application/octet-stream');
  39. header('Content-Disposition: attachment; filename='.basename($file));
  40. header('Content-Transfer-Encoding: binary');
  41. header('Expires: 0');
  42. header('Cache-Control: private');
  43. header('Pragma: private');
  44. header('Content-Length: ' . filesize($file));
  45. ob_clean();
  46. flush();
  47. readfile($file);
  48.  
  49. exit;
  50. } else {
  51. // $_SESSION['pesan'] = "Oops! File - $filename - not found ...";
  52. // header("location:laporanBulanan.php");
  53.  
  54. echo "eroor";
  55. }
  56. }
  57. ?>
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement