SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | include "../koneksi.php"; | |
| 3 | $no = 1; | |
| 4 | ||
| 5 | $db = mysqli_query($conn, "SELECT * FROM tbl_user_permohonan"); | |
| 6 | while($row = mysqli_fetch_array($db)){
| |
| 7 | $potong = $row['file']; | |
| 8 | $fix_potong = substr($potong,22); | |
| 9 | ?> | |
| 10 | ||
| 11 | <tr> | |
| 12 | <td><?php echo $no++ ?></td> | |
| 13 | <td><?php echo $row['unit_cabang']; ?> </td> | |
| 14 | <td><?php echo $fix_potong ; ?> </td> | |
| 15 | <td><?php echo $row['tanggal']; ?> </td> | |
| 16 | <th> | |
| 17 | ||
| 18 | <!-- button download file --> | |
| 19 | <a href="download.php?filename=<?=$row['file'] ?>" type="button" class="btn btn-primary" > | |
| 20 | <i class="fas fa-fw fa-edit"></i> Download</a></th> | |
| 21 | </tr> | |
| 22 | ||
| 23 | =============================================================================== | |
| 24 | ||
| 25 | <?php | |
| 26 | ||
| 27 | //include "../koneksi.php"; | |
| 28 | - | include "../koneksi.php"; |
| 28 | + | |
| 29 | if (isset($_GET['filename'])) {
| |
| 30 | ||
| 31 | $filename = $_GET['filename']; | |
| 32 | ||
| 33 | $file = "../laporan-permohonan/".$_GET['filename']; | |
| 34 | ||
| 35 | if (file_exists($file)) {
| |
| 36 | header('Content-Description: File Transfer');
| |
| 37 | header('Content-Type: application/octet-stream');
| |
| 38 | header('Content-Disposition: attachment; filename='.basename($file));
| |
| 39 | header('Content-Transfer-Encoding: binary');
| |
| 40 | header('Expires: 0');
| |
| 41 | ||
| 42 | - | header('Cache-Control: private');
|
| 42 | + | |
| 43 | - | header('Pragma: private');
|
| 43 | + | |
| 44 | flush(); | |
| 45 | //readfile($file); | |
| 46 | $f=file_get_contents($file); | |
| 47 | - | readfile($file); |
| 47 | + | echo $f; |
| 48 | - | |
| 48 | + | |
| 49 | } else {
| |
| 50 | // $_SESSION['pesan'] = "Oops! File - $filename - not found ..."; | |
| 51 | // header("location:laporanBulanan.php");
| |
| 52 | ||
| 53 | echo "eroor"; | |
| 54 | } | |
| 55 | } | |
| 56 | ?> | |
| 57 | ||
| 58 | ||
| 59 | ||
| 60 | ||
| 61 | ||
| 62 | ||
| 63 | ||
| 64 |