Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Tentukan folder id_file yang boleh di download
- $folder = "../doc/";
- // Lalu cek menggunakan fungsi id_file_exist
- if (!file_exists($folder.$_GET['id_file'])) {
- echo "<h1>Access forbidden!</h1>
- <p> </p>
- <p> Anda tidak diperbolehkan mendownload id_file ini.</p>";
- exit;
- }
- // Apabila mendownload id_file di folder id_files
- else {
- header("Content-Type: octet/stream");
- header("Content-Disposition: attachment;
- filename=\"".$_GET['id_file']."\"");
- $fp = fopen($folder.$_GET['id_file'], "r");
- $data = fread($fp, id_filesize($folder.$_GET['id_file']));
- fclose($fp);
- print $data;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment