zoukankan      html  css  js  c++  java
  • LINUNX下PHP下载中文文件名代码

     

            function get_basename($filename){    
                return preg_replace('/^.+[\\\/]/'''$filename);    
             }   
     
            $file "/tmp/你好.txt";
            $filename get_basename($file);
     
            header("Content-type: application/octet-stream");
     
            //处理中文文件名
            $ua $_SERVER["HTTP_USER_AGENT"];
            $encoded_filename urlencode($filename);
            $encoded_filename str_replace("+","%20",$encoded_filename);
            if (preg_match("/MSIE/"$ua){
             header('Content-Disposition: attachment; filename="' $encoded_filename '"');
            else if (preg_match("/Firefox/"$ua){
             header("Content-Disposition: attachment; filename*="utf8''" $filename '"');
            else {
             header('Content-Disposition: attachment; filename="' $filename '"');
            }
         
            header("Content-Length: "filesize($file));
            readfile($file);
  • 相关阅读:
    20189207《网络攻防实践》第一周作业
    事件冒泡
    链接分类
    JS:offsetWidth\offsetleft
    JS alert()、confirm()、prompt()的区别
    this用法
    事件绑定
    clippath
    浅谈正则
    C++大师Lippman:我对中国程序员的忠告(转载)
  • 原文地址:https://www.cnblogs.com/flyfish2012/p/5782008.html
Copyright © 2011-2022 走看看