環境:
Windows 7 32位元
WAMP 2.5
(Apache : 2.4.9 MySQL : 5.6.17 PHP : 5.5.12)
問題 : 使用rename時,得到no such file or directory的錯誤訊息
以下是部份code
if($_FILES['new_dutyimg']['error'] == 0){ //表示圖片上傳ok
$temp = pathinfo($_FILES['new_dutyimg']['name']);
$newtemp = 'temp1.' . $temp['extension'];
//設定存檔路徑及搭配英文檔名
$upload_file = UPLOAD_PATH . "duty_img/" . $newtemp;
}
if(move_uploaded_file($_FILES['new_dutyimg']['tmp_name'], $upload_file))
{
ImageResize($upload_file, $upload_file, 320, 240);
}
在duty_img資料夾底下,確實出現了修改檔名且已縮圖的temp1
但是接下來要將temp1改名成中文名稱的時候出現error
$newname = mb_convert_encoding(UPLOAD_PATH . "duty_img/" .
$new_dutyname . '.' . $temp['extension'] , 'big5');
rename('\'' . $upload_file . '\'', '\'' . $newname . '\''); <