How can the unlink function be integrated into a link for file deletion in PHP?
To integrate the unlink function into a link for file deletion in PHP, you can create a PHP script that accepts the file path as a parameter and then uses the unlink function to delete the file. This script can be called from a link by passing the file path as a query parameter.
<?php
if(isset($_GET['file'])) {
$file = $_GET['file'];
if(file_exists($file)) {
unlink($file);
echo "File deleted successfully.";
} else {
echo "File not found.";
}
}
?>
```
To call this script from a link, you can use the following HTML code:
```html
<a href="delete_file.php?file=path/to/your/file.txt">Delete File</a>