Moving Files with rename( ) : rename « File Directory « PHP






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";
    }
?>
  
  








Related examples in the same category

1.A file can be renamed with the rename() function
2.Moving a file