moving a text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

moving a text file

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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]
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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");
Post Reply