至尊技术网 - 生成文件
2022-11-04T14:33:00+08:00
Typecho
https://www.zzwws.cn/feed/atom/tag/%E7%94%9F%E6%88%90%E6%96%87%E4%BB%B6/
https://www.zzwws.cn/archives/6367/
2022-11-04T14:33:00+08:00
2022-11-04T14:33:00+08:00
悠悠楠杉
http://www.zzwws.cn
<?php
header("Content-Type: application/octet-stream");
$filename = "1.txt";
$content = '这里是需要生成文件的内容';
$ua = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
header('Content-Disposition: attachment; filename*="' . $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
echo $content;
]]>