Function | Description |
---|---|
copy($oldname, $newname) | Copies the file with the old filename to the file with the new filename. If successful, returns TRUE. |
rename($oldname, $newname) | Renames the file with the old filename to the new filename. If successful, returns TRUE. |
unlink($name) | Deletes the specified file. If successful, returns TRUE. |
$name1 = 'message.txt'; $name2 = 'message_2.txt'; if (file_exists($name1)) { $success = copy($name1, $name2); if ($success) { echo("File was copied.<br />"); } }
$name2 = 'message_2.txt'; $name3 = 'message_copy.txt'; if (file_exists($name2)) { $success = rename($name2, $name3); if ($success) { echo("File was renamed.<br />"); } }
$name3 = 'message_copy.txt'; if (file_exists($name3)) { $success = unlink($name3); if ($success) { echo("File was deleted.<br />"); } }