download.php
[php]
//获取传递的文件名
$filename = $_GET[‘filename’];
$pathname = “$./download/$filename”;
//以只读方式打开文件
$handle = fopen($pathname,”rb”);
//返回数据的内容类型
//’octet-stream’八位二进制流
//’content-desposition:attachment’以附件形式打开
header(“content-type:application/octet-stream”);
header(“content-despositon:attachment;filename=$filename”);
//循环读取指定大小的内容,并输出
while($str=fread($handle,1024))
{
echo $str;
}
//关闭文件
fclose($handle);
?>
[/php]
download.html
[html]
Document[/html]