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);
  • 相关阅读:
    Cocos Creator之生命周期函数
    Cocos Creator之基本概念
    Cocos Creator之菜单栏和工具栏
    Cocos Creator之认识
    lvs nat模式+iptables实现fullnat
    k8s cpu绑定
    arp代理
    确定veth pair在容器和宿主机的对应关系
    k8s 滚动发布
    http长连接
  • 原文地址:https://www.cnblogs.com/flyfish2012/p/5782008.html
Copyright © 2011-2022 走看看