IE에서 파일 다운로드를 구현하는 PHP 코드
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-07-25 09:03:47
-
- if( empty($_GET['FileName'])|| empty($_GET['FileDir'])|| empty($_GET['FileId'])){
- echo'<script> alert("非法连接 !"); location.replace ("index.php") </script>'; exit();
- }
- $file_name=$_GET['FileName'];
- $file_dir=$_GET['FileDir'];
- $FileId=$_GET['FileId'];
- $file_dir = $file_dir."/";
- if (!file_exists($file_dir.$file_name)) { //检查文件是否存在
- echo "文件找不到";
- exit;
- } else {
- $file = fopen($file_dir . $file_name,"r"); // 打开文件
- // 输入文件标签
- Header("Content-type: application/octet-stream");
- Header("Accept-Ranges: bytes");
- Header("Accept-Length: ".filesize($file_dir . $file_name));
- Header("Content-Disposition: attachment; filename=" . $file_name);
- // 输出文件内容
- echo fread($file,filesize($file_dir . $file_name));
- fclose($file);
- exit();
- }
- ?>
复制代码
|
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11