How can PHP be utilized to create a download prompt for files, similar to executable files?
To create a download prompt for files using PHP, you can use the header() function to set the content type to application/octet-stream and specify the file name to prompt the user to download the file. You can also use readfile() function to output the file contents to the user for download.
<?php
$file = 'example.zip'; // specify the file you want to prompt for download
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
?>