<?php
function
down(
$filename
,
$title
=
''
){
$file
=
fopen
(
$filename
,
"r"
);
$filesize
=
filesize
(
$filename
);
$encoded_filename
= urlencode(
$title
);
$encoded_filename
=
str_replace
(
"+"
,
"%20"
,
$title
);
$ua
=
$_SERVER
[
"HTTP_USER_AGENT"
];
if
(preg_match(
"/MSIE/is"
,
$ua
)) {
$file_name
= urlencode(
$title
);
header(
"Pragma: public"
); header(
"Expires: 0"
);
header(
"Cache-Control: must-revalidate, post-check=0, pre-check=0"
);
header(
"Content-Type: application/force-download"
);
header(
'Content-Type: application/vnd.ms-excel; charset=utf-8'
);
header(
"Content-Transfer-Encoding: binary"
);
header(
'Content-Disposition: attachment; filename='
.
$file_name
);
}
else
{
header(
'Content-Type: application/octet-stream'
);
if
(preg_match(
"/Firefox/is"
,
$ua
)) {
header(
'Content-Disposition: attachment; filename*="utf8\'\''
.
$title
.
'"'
);
}
else
{
header(
'Content-Disposition: attachment; filename="'
.
$title
.
'"'
);
}
}
echo
fread
(
$file
,
$filesize
);
fclose(
$file
);
}
?>