tags:

views:

51

answers:

3

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?

A: 

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);
}
kgb
A: 

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

Miroslav Asenov
A: 

Did you enclose strings in quotes?

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

Codex73