Page 1 of 1

how to use rename() function?

Posted: Wed Aug 25, 2010 1:17 am
by geniussadi
I have a lot of experience working with PHP, but I'm unable to make rename() working for me.

I'm getting this error.
Warning: rename(c:/zerocall_cdr/Cdr_1282293451.csv,c:/zerocall_cdr/error/Cdr_1282293451.csv) [function.rename]: No such file or directory in .... .php on line 162
And this is the code,

Code: Select all

$root_dir = 'c:/zerocall_cdr';
$backup_dir = $root_dir.'/backup';

$file = "Cdr_1282293451.csv";

rename("$root_dir/$file", "$backup_dir/$file");
Let me know what I'm doing wrong in it?

Re: how to use rename() function?

Posted: Wed Aug 25, 2010 1:34 am
by amargharat
The error you are getting is about no existence of directory or file.
So, make sure about directory exists or not.

In your code, u r renaming from root to root/backup

but in u r error, destination path contains root/error/filename.

So, that causes the error