Home Tutorial Php Phpfiles Copy file in php, How to copy file in php, PHP copy file

 
 

Share on Google+Share on Google+
Copy file in php, How to copy file in php, PHP copy file
Posted on: September 21, 2009 at 12:00 AM
Advertisement
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

<?php

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

$file2=fopen("bb.txt","w"); 

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

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

echo"<br>";

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

?>

Output

1
this is roseindia

 

Advertisement

Related Tags for Copy file in php, How to copy file in php, PHP copy file:


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.

Posted on: September 21, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com