2010-03-13 53 views
3

雖然文件仍然移動到正確的目錄中,但我仍然收到此錯誤。有人知道我爲什麼得到這個錯誤?錯誤在PHP中使用重命名功能

Warning: rename(../Images/uploaded/1162504_56863010.jpg,../Images/uploaded/Portraits/1162504_56863010.jpg) [function.rename]: No error in D:\Data\Websites\wamp\www\StephsSite\PHP\addImage.php on line 21 
+1

的PHP和版本你使用OS嗎?如果可能,嘗試更新到最新版本。可能與http://bugs.php.net/48771 – VolkerK 2010-03-13 23:34:25

+0

有關你使用哪個PHP版本?有一個與此前5.3版本相關的bug:http://bugs.php.net/bug.php?id=48771&edit=2 – 2010-03-13 23:34:32

+0

@VolkerK,你打敗了我:-) – 2010-03-13 23:35:06

回答

5

按照User Contributed Notesrename(),有當目標文件已存在於Windows系統中的問題。

  • 嘗試unlink()第一荷蘭國際集團的目標文件(如果存在)
  • 或者,嘗試copy()
+0

這可能是當試圖移動到不同的卷https://bugs.php.net/bug.php?id=50676 – 2014-07-24 08:48:14

0

一種可能性是簡單地隱藏警告:

error_reporting(E_ALL & ~E_WARNING); 
rename($old_name, $new_name); 
error_reporting(E_ALL & ~E_NOTICE);