<?php
$oldname = 'D:afile.zip';
$newName = 'D:aöÖçÇİfile.zip';
//$newName = 'D:aooCCifile.zip'; it's work
rename($oldname, $newName);
?>
错误:
Warning: rename(D:afile.zip,D:aöÖçÇİfile.zip): The system cannot find the path specified. (code: 3) in C:UsersDesktoprename.php on line 9
我试过";url编码"iconv";但是没有起作用。
文件路径需要编码为UTF-16,Windows才能识别它。由于我的PHP源代码是用编码保存的"UTF-8";,我用过这个:
$oldname = 'D:afile.zip';
$newName = 'D:aöÖçÇİfile.zip';
$newName = iconv("UTF-8", "UTF-16", $newName);
$copyIslem = copy($oldname, $newName);