Tuesday, April 17, 2007

PHP Copying and Deleting Files

To copy a file, the copy() function is used:

bool copy(string source_file,string destination_file)


The copy() function will return true if the file was correctly copied, or false if there was an error.

$log_folder = "logs";
$log_name1 = "logs.txt";
if (!(copy($log_folder,$log_name1))) { echo "Error copying $log_name1 to $log_folder"; }
else { echo "File successfully copied"; }
?>

No comments: