中文乱码寻求解决~~~~~ 中文文件名乱码的原因是:php的file函数库不支持中文文件名,凡是文件名一律按单字节处理。不知道我说的对不对而且,在制作网页中使用中文文件名是个非常不好的做法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 中文文件名是客户要求嘛~~~~~~ 上传中文文件名的时候显示乱码的.找到了其中几个函数读取文件名的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 ) ) ;}稍微一改就不显示文件了郁闷啊~~~~~~~~~ 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>' ;} 求助:如何安装 php的 ID3 Tags php求助 &转义的问题 帮我改一下这个php.显示ip的问题: session跨域问题 一个有难度的字符串处理问题! 小弟想做一个探针吧,请大家帮下忙 留言板中添加非本人写的内容不可修改的功能如何填写 出现php.4.2.3注册session_register的问题,帮我 怎样把变量写入sql? 请大家帮帮我啊 为什么我的php程序不能传递数据,form问题
上传中文文件名的时候显示乱码的.
找到了其中几个函数读取文件名的
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 ) ) ;
}
稍微一改就不显示文件了
郁闷啊~~~~~~~~~
完整的函数
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>' ;
}