1 <?
2 if( empty($_GET['FileName'])|| empty($_GET['FileDir'])|| empty($_GET['FileId'])){
3 echo'<script> alert("非法连接 !"); location.replace ("index.php") </script>'; exit();
4 }
5 $file_name=$_GET['FileName'];
6 $file_dir=$_GET['FileDir'];
7 $FileId=$_GET['FileId'];
8 $file_dir = $file_dir."/";
9 if (!file_exists($file_dir.$file_name)) { //检查文件是否存在
10 echo "文件找不到";
11 exit;
12 } else {
13 $file = fopen($file_dir . $file_name,"r"); // 打开文件
14 // 输入文件标签
15 Header("Content-type: application/octet-stream");
16 Header("Accept-Ranges: bytes");
17 Header("Accept-Length: ".filesize($file_dir . $file_name));
18 Header("Content-Disposition: attachment; filename=" . $file_name);
19 // 输出文件内容
20 echo fread($file,filesize($file_dir . $file_name));
21 fclose($file);
22 exit();
23 }
24 ?>
2 if( empty($_GET['FileName'])|| empty($_GET['FileDir'])|| empty($_GET['FileId'])){
3 echo'<script> alert("非法连接 !"); location.replace ("index.php") </script>'; exit();
4 }
5 $file_name=$_GET['FileName'];
6 $file_dir=$_GET['FileDir'];
7 $FileId=$_GET['FileId'];
8 $file_dir = $file_dir."/";
9 if (!file_exists($file_dir.$file_name)) { //检查文件是否存在
10 echo "文件找不到";
11 exit;
12 } else {
13 $file = fopen($file_dir . $file_name,"r"); // 打开文件
14 // 输入文件标签
15 Header("Content-type: application/octet-stream");
16 Header("Accept-Ranges: bytes");
17 Header("Accept-Length: ".filesize($file_dir . $file_name));
18 Header("Content-Disposition: attachment; filename=" . $file_name);
19 // 输出文件内容
20 echo fread($file,filesize($file_dir . $file_name));
21 fclose($file);
22 exit();
23 }
24 ?>