How can a "delete" link/button be created next to a download link in PHP for deleting specific files?

To create a "delete" link/button next to a download link in PHP for deleting specific files, you can use a combination of HTML and PHP. You can create a form with a hidden input field containing the file path and a submit button styled as a link or button. When the form is submitted, you can use PHP to delete the specified file using the unlink() function.

<!-- HTML code for displaying download and delete links -->
<a href="download.php?file=file.pdf">Download file</a>
<form action="delete.php" method="post">
    <input type="hidden" name="file" value="file.pdf">
    <button type="submit">Delete file</button>
</form>

<?php
// delete.php - PHP code to delete the specified file
if(isset($_POST['file'])) {
    $file = $_POST['file'];
    if(file_exists($file)) {
        unlink($file);
        echo "File deleted successfully.";
    } else {
        echo "File not found.";
    }
}
?>