Page 1 of 1

moving a text file

Posted: Tue Feb 17, 2004 12:12 pm
by cto1mac
Ok, I have a text file that gets updated daily. But, i need to keep the old text files for historical purposes. How can I do this in PHP?? I need to move the old file to a different directory and change the name to have the date on it

ie: old text file: test.txt
move to old_text_files/02-17-04.txt

then i need the new text file to be written in its place with the old name of test.txt.

Thanks

Posted: Tue Feb 17, 2004 3:19 pm
by Weirdan

Code: Select all

rename('test.txt',"old_text_files/".date("m-d-y")."txt");
[php_man]rename[/php_man],[php_man]date[/php_man]

Posted: Tue Feb 17, 2004 3:30 pm
by ol4pr0
or use the

Code: Select all

copy()

Code: Select all

copy("/usr/local/apache2/htdocs/text.txt", "/old_text_files/".date("m-d-y")."txt");