Advertisement
GWibisono

harusnya gini kk disesuaikan dgn kebutuhan

Feb 8th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Tentukan folder id_file yang boleh di download
  3. $folder = "../doc/";
  4. if(!isset($_GET['id_file'])){
  5.     die('tidak ada id_file yg dibuka');
  6. }
  7. // Lalu cek menggunakan fungsi id_file_exist
  8. if (!file_exists($folder.$_GET['id_file'])) {
  9.   echo "<h1>Access forbidden!</h1>
  10. <p>&nbsp;</p>
  11. <p> File yang anda cari tidak ada.</p>";
  12.   exit;
  13. }
  14. else { // Apabila mendownload id_file di folder id_files
  15.   header("Content-Type: octet/stream");
  16. //===============
  17.     $name=trim(strtolower($_GET['id_file']) );
  18.   header("Content-Disposition: attachment; filename=\"".$name."\"");
  19. /*
  20.   $fp = fopen($folder.$_GET['id_file'], "r");
  21.   $data = fread($fp, id_filesize($folder.$_GET['id_file']));
  22. */
  23.     $data=file_get_contents($folder.$_GET['id_file']);
  24.   //fclose($fp);
  25.   print $data;
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement