- Header (' content-type:application/pdf ');
- Header (' content-disposition:attachment; filename= ' downloaded.pdf ');
- ReadFile (' original.pdf ');
- ?>
Copy CodeDescription of the above code: the first sentence, just change the type of the document, for example, to download the TXT file, then the header (' Content-type:application/txt '), the second sentence is for your download document name, if it is a TXT file , you can change the header (' content-disposition:attachment; filename= ' Downloaded.txt '); the third sentence, ReadFile This function means to read a file and then output, The path of the file here needs to be the real file path, if it is a original.txt file under the Downloads folder, you can write ReadFile (' Downloads/original.txt '), and if the submitted page will output characters such as text , then the downloaded file will be a mixed file of the original file original.txt and the text of the submitted page output. With the above understanding, the implementation of the TXT file download, you can also easily solve. In addition, for the convenience of understanding, it is recommended to read the following: PHP header Content-type Type summarizes this article, summarizes the very comprehensive PHP header content type. |