<?php //下载的源文件是utf-8编码, //但是确用gbk浏览,所以乱码 //在这里把文件名修改为gbk编码 header("content-Type: text/html; charset=GBK"); //变量文件夹 $dir = opendir("file"); $path="file/"; //列出 images 目录中的文件 while (($old_name = readdir($dir)) !== false) { echo "filename: " . $old_name . "<br />"; $new_name=mb_convert_encoding($old_name,"GBK", "UTF-8"); if (file_exists($path.$old_name)){ if (rename($path.$old_name,$path.$new_name )) //把原文件重新命名 {echo "修改成功!";} }else{ print $old_name."文件不存在!<br>" ; } } closedir($dir); exit; ?>
修改文件夹下,文件名编码
最新推荐文章于 2024-04-16 15:24:00 发布