$ua = $_server["Http_user_agent"];
- $filename = "Chinese filename. txt";
- $encoded _filename = UrlEncode ($filename);
- $encoded _filename = str_replace ("+", "%20", $encoded _filename);
$ua = $_server["Http_user_agent"];
- $filename = "Chinese filename. txt";
- $encoded _filename = UrlEncode ($filename);
- $encoded _filename = str_replace ("+", "%20", $encoded _filename);
- ?>
Copy CodeThe above code can support the download of Chinese file names. 2. Generate TXT file
Header ("Content-type:application/octet-stream");
- if (Preg_match ("/msie/", $_server[' Http_user_agent '])) {
- Header (' content-disposition:attachment; filename= '. $encoded _filename. '"');
- } elseif (Preg_match ("/firefox/", $_server[' Http_user_agent '])) {
- Header (' content-disposition:attachment; filename*= ' UTF8 '. $filename. '"');
- } else {
- Header (' content-disposition:attachment; Filename= '. $filename. '"');
- }
Header ("Content-type:application/octet-stream");
- if (Preg_match ("/msie/", $_server[' Http_user_agent '])) {
- Header (' content-disposition:attachment; filename= '. $encoded _filename. '"');
- } elseif (Preg_match ("/firefox/", $_server[' Http_user_agent '])) {
- Header (' content-disposition:attachment; filename*= ' UTF8 '. $filename. '"');
- } else {
- Header (' content-disposition:attachment; Filename= '. $filename. '"');
- }//compatible with various browsers.
- ?>
Copy Code3, the output of this step is much simpler, directly with the echo output, "\ r \ n" for the line. The content of the output is the content in txt. This feature can also generate a doc file, as long as the suffix is changed to. doc, but only a simple doc file can be generated in this way, and if there is a picture or link, you can only find another path. Scripting School, I wish you a pleasant study. |