How to use copy in PHP Filesystem

In this article I am going to explain about copy function in PHP Filesystem.
  • 1582

PHP copy() function

The filesystem copy function is used to copies a file and it returns true on success otherwise return false.

Syntax of copy function

copty(file, tofile)

Parameters in copy function

It have two  parameter:

Parameter Description
file Path to the source file.
tofile Path of the destination file.

Example of filesystem copy function




$file = 'C:\wamp\www\Dinesh\Mcn.txt';

$newfile = 'C:\wamp\www\Dinesh\Mcn1.txt';


if (!copy($file, $newfile)) {

    echo "failed to copy $file...\n";


    echo "copied $file into $newfile\n";






copy function.jpg

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2019 DotNetHeaven. All rights reserved.