View difference between Paste ID: RScy5tv6 and JMSKhKi4
SHOW: | | - or go back to the newest paste.
1
<?php
2
// Tentukan folder id_file yang boleh di download
3
$folder = "../doc/";
4-
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-
<p> Anda tidak diperbolehkan mendownload id_file ini.</p>";
9+
10
<p>&nbsp;</p>
11
<p> File yang anda cari tidak ada.</p>";
12-
12+
13-
// Apabila mendownload id_file di folder id_files
13+
14-
else {
14+
else { // Apabila mendownload id_file di folder id_files
15
  header("Content-Type: octet/stream");
16-
  header("Content-Disposition: attachment; 
16+
//===============
17-
  filename=\"".$_GET['id_file']."\"");
17+
	$name=trim(strtolower($_GET['id_file']) );
18
  header("Content-Disposition: attachment; filename=\"".$name."\"");
19
/*
20-
  fclose($fp);
20+
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
?>