How can PHP be used to hide file paths in a download link?

When providing a download link in PHP, you can use a combination of file handling functions and headers to hide the actual file path from the user. By using PHP to read the file and output it to the user, you can prevent direct access to the file path. This helps to protect sensitive information about the file location on the server.

<?php
$file = 'path/to/your/file.pdf';
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile($file);
exit;
?>