Copying Files in PHP

Copying Files in PHP: 
The copy() function is very simple: It needs to know the original filename and a new filename, and that’s all there is to it.

<?php
$orig_filename = “e:/ashu2.txt”;
$new_filename = “e:/ashu2.bak”;
$success = @copy($orig_filename, $new_filename) or die (“Unable to copy file”);
if($success)
{
$msg = “file $orig_filename copied in $new_filename”;
}
else
{
$msg = “Error copying file”;
}
?>
<html>
<head>
<title>
File Copying Script
</title>
</head>
<body>
<? echo $msg; ?>
</body>
</html>

                                             

                                                  

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *