PHP/File Directory/rename
A file can be renamed with the rename() function
Its syntax is: bool rename (string oldname, string newname)
<?
$data_file = "data.txt";
rename($data_file, $data_file.".old") or die("Could not rename $data_file");
?>
Moving a file
<?php
$old = "/tmp/today.txt";
$new = "/tmp/tomorrow.txt";
rename($old,$new) or die("couldn"t move $old to $new: $php_errormsg");
?>
Moving Files with rename( )
<?
$filename = "data.txt";
$filename2 = $filename . ".old";
$result = rename($filename, $filename2);
if ($result) {
print "$filename has been renamed to $filename2.\n";
} else {
print "Error: couldn"t rename $filename to $filename2!\n";
}
?>