Description:
To rename a file you use the rename() function.
this function also allows you to move a file to a different directory.
Code:
<?php
$myfile = './check.txt';
$newfile = './change.txt';
if(rename($myfile,$newfile))
{
echo sprintf("%s was renamed to %s",$myfile,$newfile);
}
else
{
echo 'An error occurred during renaming the file';
}
To rename a file you use the rename() function.
this function also allows you to move a file to a different directory.
Code:
<?php
$myfile = './check.txt';
$newfile = './change.txt';
if(rename($myfile,$newfile))
{
echo sprintf("%s was renamed to %s",$myfile,$newfile);
}
else
{
echo 'An error occurred during renaming the file';
}
?>
Output:
No comments:
Post a Comment