王学昌的笔记

Orioner.Wang

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

[转]docman 组件下载中文名文件时乱码的解决办法

找到DOCMAN_file.class.php文件中的download函数定义,修改成
function download($inline = false)
    {
// Fix [3164]
while (@ob_end_clean());

if( $this->_isLink ){
header( "Location: " . substr( $this->name , 6 ) );
return;
}

$fsize = @filesize($this->path.$this->name);
$mod_date = date('r', filemtime( $this->path.$this->name ) );

$cont_dis = $inline ? 'inline' : 'attachment';

// required for IE, otherwise Content-disposition is ignored
if(ini_get('zlib.output_compression'))  {
ini_set('zlib.output_compression', 'Off');
}

        header("Pragma: public");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Expires: 0");

        header("Content-Transfer-Encoding: binary");
header('Content-Disposition:' . $cont_dis .';'
. ' filename="' . iconv('utf-8','gb2312',$this->name) . '";' //iconv为php中转换字符编码的函数。
. ' modification-date="' . $mod_date . '";'
. ' size=' . $fsize .';'
); //RFC2183
        header("Content-Type: "    . $this->mime ); // MIME type
        header("Content-Length: "  . $fsize);

        if( ! ini_get('safe_mode') ) { // set_time_limit doesn't work in safe mode
    @set_time_limit(0);
        }

  // No encoding - we aren't using compression... (RFC1945)
//header("Content-Encoding: none");
//header("Vary: none");


        $this->readfile_chunked($this->path.$this->name);
        // The caller MUST 'die();'
    }
 
只修改了第21行的代码,原21行代码为
. ' filename="' . $this->name . '";'
内容的浏览数 : 276302