首页 >php教程 >PHP源码 >php实现文件下载的一段代码

php实现文件下载的一段代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-08 17:32:38949浏览
<script>ec(2);</script>


$file_dir=$totalDirectory;
     $file_name=$filename;
     //echo ''./db/''.$file_dir.$file_name;
    if (file_exists($file_dir.$file_name)){
          $file=fopen($file_dir.$file_name,''r'');
         Header(''Content-type:application/octet-stream'');
         Header(''Accept-Ranges:bytes'');
         Header(''Content-Disposition:attachment;filename=''.$file_name);
         echo fread($file,filesize($file_dir.$file_name));
         fclose($file);
         exit;
        
     }else{
         echo ''file is not exists'';
     }





声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn