Guest User

Untitled

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