PHP allows you to change the HTTP headers that you write so that you can force a file to be downloaded, typically, the browser will load the files in the same window. This is perfect for documents such as PDF files, document files, pictures, videos that you want your customers to download, rather than read online.
Here's how:
1, you want to download the file to your Web server to upload. For example
Huge_document.pdf
2. Edit the new php file-I recommend naming it as the same as the name of the file you downloaded, just to PHP extensions. 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, and 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. Links to the download link to your php file. For example:
Download huge files (PDF)
http://www.bkjia.com/PHPjc/477926.html www.bkjia.com true http://www.bkjia.com/PHPjc/477926.html techarticle PHP allows you to change the HTTP headers that you write so that you can force a file to be downloaded, typically, the browser will load the files in the same window. This is the perfect document, such as ...