Home >Backend Development >PHP Tutorial >PHP code to implement browser click download of TXT document
Instructions: The first header function sets the value of Content-Type to application/force-download; The second header function sets the file to be downloaded. Note that filename here is a file name that does not include a path. The value of filename will be the file name in the dialog box that pops up after clicking download. If there is a path, the file name in the dialog box that pops up is unknown; Finally, the file stream is output to the browser through the readfile function, thus realizing the download of the txt file. |