Share on Google+Share on Google+

Copy file in php, How to copy file in php, PHP copy file

In this example code I will show you how you can copy files in PHP program.

Learn How to copy file in php. The PHP copy file example explained here copies the content of one file (aa.tx) into another file (bb.txt). 

In the following example we will show you how to use of copy() function in php. The copy function in PHP is used to copy the content of one file into another file.

Syntax of Copy file in PHP

boolean copy ( string $source_file, string $target_file )

The copy function copies the content of source_file into target_file. It returns the true or false Value.

Copy file example code


$file1=fopen("aa.txt","w");//Open the file into write mode


fwrite($file1,"this is roseindia",30);

echo copy("aa.txt","bb.txt");//Copy the content of aa.txt into bb.txt


echo fread($file2,30);//Display the content of bb.txt



this is roseindia



Posted on: September 21, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null