PHP重命名错误

发布于 2024-09-08 18:40:20 字数 341 浏览 1 评论 0原文

当使用重命名函数

Warning: rename(../data/feeds/feed2.txt,../data/feeds/feed3.txt) [function.rename]: No error in C:\wamp\www\cms\admin\pages\feeds.php on line 32

“../data/feeds/feed2.txt”是正确的路径时,我收到此错误,我已经完成了 include("../data/feeds/feed2.txt") 并且它显示了该文件。并且“../data/feeds/feed3.txt”不存在。

有谁知道这是什么原因造成的?

I get this error when using the rename function

Warning: rename(../data/feeds/feed2.txt,../data/feeds/feed3.txt) [function.rename]: No error in C:\wamp\www\cms\admin\pages\feeds.php on line 32

"../data/feeds/feed2.txt" is the correct path, I have done include("../data/feeds/feed2.txt") and it displays the file. And "../data/feeds/feed3.txt" doesn't exist.

Anyone know what's causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别念他 2024-09-15 18:40:20

您应该检查“../data/feeds/feed2.txt”是否可读以及“../data/feeds/feed3.txt”是否可写...

$oldname = '';
$newname = '';
if (
    file_exists($oldname)&&
    (
        (!file_exists($newname))||
        is_writable($newname)
    )
) {
    rename($oldname, $newname);
}

you should check if "../data/feeds/feed2.txt" is readable and if "../data/feeds/feed3.txt" is writable...

$oldname = '';
$newname = '';
if (
    file_exists($oldname)&&
    (
        (!file_exists($newname))||
        is_writable($newname)
    )
) {
    rename($oldname, $newname);
}
小猫一只 2024-09-15 18:40:20

您是否将字符串括在引号中?

rename('../data/feeds/feed2.txt','../data/feeds/feed3.txt');

Did you enclose strings in quotes?

rename('../data/feeds/feed2.txt','../data/feeds/feed3.txt');
非要怀念 2024-09-15 18:40:20

您可以在 try-catch 语句中使用: copy( $old_name, $new_name ); unlink($old_name);

只是您必须确保该目录是可写的。

在您的情况下,您必须确保该目标文件存在或使用绝对文件路径

You can use in try-catch statements : copy( $old_name, $new_name ); unlink($old_name);

Just you must be sure that directory is writable.

In your case u must be sure that this destination file is exists or use absolute file paths

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文