您的位置:首页 > 编程语言 > PHP开发

php代码生成txt文件并下载

2013-05-24 14:37 1491 查看
php代码生成txt文件并下载
<?php
header("Content-Type: application/octet-stream");

$quan=$_GET['quan'];
$ua = $_SERVER["HTTP_USER_AGENT"];
$filename = "100yuan.txt";
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);

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 . '"');
header('Content-Disposition: attachment; filename*="' .  $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' .  $filename . '"');
}

echo '您已领取100元现金券。现金券编码是:'.$quan;
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 下载 生成txt文件