简体   繁体   English

在PHP中使用重命名函数时出错

[英]error using rename function in PHP

I keep getting this error, although the file still gets moved into the correct directory. 虽然文件仍然被移动到正确的目录中,但我仍然收到此错误。 Anybody know why i'm getting this error? 有谁知道我为什么会收到这个错误?

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

According to the User Contributed Notes to rename() , there are issues on Windows systems when the target file already exists. 根据用户贡献的 rename() 注释 rename() ,当目标文件已存在时,Windows系统上存在问题。

One possibility is simply to hide the warning: 一种可能性就是隐藏警告:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM