中文文件名乱码的原因是:php的file函数库不支持中文文件名,凡是文件名一律按单字节处理。不知道我说的对不对而且,在制作网页中使用中文文件名是个非常不好的做法。

解决方案 »

  1.   

    中文文件名是客户要求嘛~~~~~~ 
    上传中文文件名的时候显示乱码的.
    找到了其中几个函数读取文件名的
    function GetFoldersAndFiles( $resourceType, $currentFolder )
    {
    globals $sss;
    // Map the virtual path to the local server path.
    $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ;
    // Initialize the output buffers for "Folders" and "Files".
    $sFolders = '<Folders>' ;
    $sFiles = '<Files>' ;
    $oCurrentFolder = opendir( $sServerDir ) ;
    while ( $sFile = readdir( $oCurrentFolder ) )
    {
    if ( $sFile != '.' && $sFile != '..' )
    {
    if ( is_dir( $sServerDir . $sFile ) )
    $sFolders .= '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
    else
    {
    $iFileSize = filesize( $sServerDir . $sFile ) ;
    if ( $iFileSize > 0 )
    {
    $iFileSize = round( $iFileSize / 1024 ) ;
    if ( $iFileSize < 1 ) $iFileSize = 1 ;
    }
    $sFiles .= '<File name="' . ConvertToXmlAttribute( $sFile ) . '" size="' . $iFileSize . '" />' ;
    }
    }
    }
    echo $sFolders ;
    // Close the "Folders" node.
    echo '</Folders>' ;
    echo $sFiles ;
    // Close the "Files" node.
    echo '</Files>' ;
    }function ConvertToXmlAttribute( $value )
    {
    return utf8_encode( htmlspecialchars( $value ) ) ;
    }
    稍微一改就不显示文件了
    郁闷啊~~~~~~~~~
      

  2.   

    globals $sss是我测试的时候加上去的,没删掉~呵呵~~~~~
    完整的函数
    function GetFoldersAndFiles( $resourceType, $currentFolder )
    {
    globals $sss;
    // Map the virtual path to the local server path.
    $sServerDir = ServerMapFolder( $resourceType, $currentFolder ) ;
    // Initialize the output buffers for "Folders" and "Files".
    $sFolders = '<Folders>' ;
    $sFiles = '<Files>' ;
    $oCurrentFolder = opendir( $sServerDir ) ;
    while ( $sFile = readdir( $oCurrentFolder ) )
    {
    if ( $sFile != '.' && $sFile != '..' )
    {
    if ( is_dir( $sServerDir . $sFile ) )
    $sFolders .= '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
    else
    {
    $iFileSize = filesize( $sServerDir . $sFile ) ;
    if ( $iFileSize > 0 )
    {
    $iFileSize = round( $iFileSize / 1024 ) ;
    if ( $iFileSize < 1 ) $iFileSize = 1 ;
    }
    $sFiles .= '<File name="' . ConvertToXmlAttribute( $sFile ) . '" size="' . $iFileSize . '" />' ;
    }
    }
    }
    echo $sFolders ;
    // Close the "Folders" node.
    echo '</Folders>' ;
    echo $sFiles ;
    // Close the "Files" node.
    echo '</Files>' ;
    }