Page 1 of 1

Copying Files In A Directory

Posted: Sat Mar 20, 2004 7:25 am
by andylyon87
How do I go about copying a file to another folder say from a dir called "form_data" to a dir called "moderated". Both these folders are within a folder called "test". I want files to move from the "form_data" folder to the "moderator" folder.

Posted: Sat Mar 20, 2004 7:29 am
by markl999
rename('test/form_data/file1.txt', 'test/moderated/file1.txt');

This will 'move' it by the way, not sure if you want to copy or move as you mention both ;) If you want to copy then see http://php.net/copy

Posted: Sat Mar 20, 2004 7:38 am
by andylyon87
To move a file could i use a function that copies the file to the second folder and deletes it from the first folder

Posted: Sat Mar 20, 2004 7:43 am
by markl999
Yeah, that's what http://php.net/rename does

Posted: Sat Mar 20, 2004 7:48 am
by andylyon87
sorry just realised :)