View Full Version : Copying the contents of one file to another

Dr. Lecter
09-10-2005, 08:53 PM
Does anyone know how to make the contents of a file a variable so they can be added to the end of another file... I tried to use !copy, not realizing that it literally copied the file onto the other. I've tried the php.net manual, but I can't find anything that works. Its probably something really simple but its been bugging me for the last hour, since I got everything else working but this.

09-10-2005, 09:11 PM
fopen() with mode a or a+
PHP5: file_put_contents() with FILE_APPEND flag

09-10-2005, 09:38 PM
Also file_get_contents()


09-10-2005, 10:51 PM
Huh? file_GET_contents()?

09-10-2005, 11:32 PM
Ahh sorry, I should have made it more clear... I was talking about an easy way to get the entire file as a string (to then be written using fopen()/fwrite()).

Dr. Lecter
09-11-2005, 12:45 AM
Can someone explain the usage of file_get_contents since I can't seem to get anything but false whenever I use it.

09-11-2005, 12:56 AM

Dr. Lecter
09-11-2005, 02:25 AM
Wow! Thanks, it works :thumbsup: