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