$file = 'test.txt'; if (!unlink($file)) { echo "Error deleting $file"; } else { echo "File $file deleted successfully"; }
$file = $_POST['filename']; if (!unlink($file)) { echo "Error deleting $file"; } else { echo "File $file deleted successfully"; }In this example, the `unlink()` function is used to delete a file whose name is sent through a form using the POST method. The filename is accessed using the `$_POST` superglobal array. This code can be used to create a form that allows users to delete files from the server. Package/Library: The PHP file delete function is a built-in function and does not require any external package or library.