copy php filesystem function example - copy a file source to destination
copy-php-filesystem-function-example.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>copy php filesystem function example - copy a file source to destination</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="copy php filesystem function example - copy a file source to destination">
<meta name="keywords" content="php, example, code, array, function, copy, string">
<meta name="description" content="copy php filesystem function example - copy a file source to destination">
<style>
h2, h4{background:orange; color:#000092;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:19px;}
p{padding:2px; margin:2px; color:#0099FE;}
body{ background:#FFFFFD;}
</style>
</head>
<body>
<h2>copy php filesystem function example - copy a file source to destination</h2>
<pre>
<?php
/*
-------------------------------------------------------
let say we have a file test.php in the same directory
we would like to make a copy of it as test2.php
-------------------------------------------------------
*/
$copyFile = "test.php";
$newCopyFile = "test2.php";
echo "<h4>File to be copied</h4>";
print "<p>$"."copyFile = {$copyFile}</p>";
print "<p>$"."newCopyFile = {$newCopyFile}</p>";
$IsFileCopy = copy($copyFile, $newCopyFile);
if($IsFileCopy)
{
print "<h4>file copy success</h4>";
}
else
{
print "<h4>file copy failed</h4>";
}
/*
--------------------------------------------------------------------------------------------------
you can add source and destination of the file along with $copyFile and $newCopyFile respectively
--------------------------------------------------------------------------------------------------
*/
/*
---------------------------------------------------------------------------------------
this function rapidly used in professional programming to copy uploaded file
from temp directory to desired directory
---------------------------------------------------------------------------------------
*/
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..