How can PHP be used to create a download button for specific files in a directory?

To create a download button for specific files in a directory using PHP, you can use the `header()` function to force the browser to download the file instead of displaying it. You can create a PHP script that accepts the file name as a parameter and then sends the appropriate headers to trigger the download.

<?php
// Specify the directory where the files are located
$directory = 'path/to/files/';

// Get the file name from the query parameter
$file = $_GET['file'];

// Check if the file exists in the directory
if (file_exists($directory . $file)) {
    // Set the appropriate headers for file download
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Content-Length: ' . filesize($directory . $file));

    // Read the file and output it to the browser
    readfile($directory . $file);
    exit;
} else {
    // File not found
    echo 'File not found.';
}
?>