[php] 특정 폴더내 파일 이름을 urlencode로 변경하기
본문
<?php
include_once("./_common.php"); // Can't access individual pages
$path = './Upload/';
$cnt = 0;
$dh = opendir($path);
while ( ($file=readdir($dh))!==false )
{
if ( !is_file($path.$file)) continue;
$oldname = basename($file);
$newname = iconv("euc-kr", "utf-8", $oldname);
rename($path.$oldname,$path.urlencode($newname));
$cnt++;
}
closedir($dh);
echo $cnt.' ok';
?>
include_once("./_common.php"); // Can't access individual pages
$path = './Upload/';
$cnt = 0;
$dh = opendir($path);
while ( ($file=readdir($dh))!==false )
{
if ( !is_file($path.$file)) continue;
$oldname = basename($file);
$newname = iconv("euc-kr", "utf-8", $oldname);
rename($path.$oldname,$path.urlencode($newname));
$cnt++;
}
closedir($dh);
echo $cnt.' ok';
?>
추천0
댓글목록 0
등록된 댓글이 없습니다.