zoukankan      html  css  js  c++  java
  • php 生成下载连接

      public function showdownload(){
    
    
           $file_url=$_GET['url'];
        $new_name='激活码';
       
        if(!isset($file_url)||trim($file_url)==''){
    
            return '500';
    
        }
    
        if(!file_exists($file_url)){ //检查文件是否存在
    
            return '404';
    
        }
    
            $file_name=basename($file_url);
    
            $file_type=explode('.',$file_url);
    
            $file_type=$file_type[count($file_type)-1];
    
            $file_name=trim($new_name=='')?$file_name:urlencode($new_name).'.'.$file_type;
    
            $file_type=fopen($file_url,'r'); //打开文件
    
            //输入文件标签
    
            header("Content-type: application/octet-stream");
    
            header("Accept-Ranges: bytes");
    
            header("Accept-Length: ".filesize($file_url));
    
            header("Content-Disposition: attachment; filename=".$file_name);
    
            //输出文件内容
    
            echo fread($file_type,filesize($file_url));
    
            fclose($file_type);
    
           
    
      }
  • 相关阅读:
    bzoj3996
    bzoj3157 3516
    bzoj1937
    bzoj1532
    bzoj3572
    bzoj1453
    bzoj3205
    bzoj2595
    关于高斯消元解决xor问题的总结
    linux查找和替换命令
  • 原文地址:https://www.cnblogs.com/hgj123/p/4537947.html
Copyright © 2011-2022 走看看