php程式碼生成txt檔案並下載
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<?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 ;
?> |