What function can be used in PHP to delete a file after it has been downloaded by a user?

To delete a file after it has been downloaded by a user in PHP, you can use the unlink() function. This function takes the file path as an argument and deletes the file from the server. You can call this function after the file has been successfully downloaded by the user to ensure that it is removed from the server.

$file_path = 'path/to/file.txt';

// Code to download the file here

// Delete the file after download
unlink($file_path);