PHP allows you to change the HTTP headers you write so that you can force a file to be downloaded, and normally the browser would load the file in the same window. This is perfect for files such as PDF files, document files, images, videos that you want your customers to download rather than read online.
The specific method is as follows:
1. Upload files you want to download to your web server. For example,
huge_document.pdf
2. Edit the new PHP file - I recommend naming it the same as the file you downloaded, just with the PHP extension. For example:
huge_document.php
3. Open the PHP module:
PHP
4. In the next line, set the HTTP header:
header('Content-disposition: attachment; filename=huge_document.pdf');
5. Then set the MIME type of the file:
header('Content-type: application/pdf');
6. Point to the file you want to download:
readfile('huge_document.pdf');
7. Then close the PHP block and save the file:
> [/ BLOCKQUOTE>
8. Your PHP file should look like this:
header('Content-disposition: attachment; filename=huge_document.pdf');
header('Content-type: application/pdf');
readfile('huge_document.pdf');
?>
9. Link to the download link of your PHP file. For example:
Download huge document (PDF)