<?php
/*
* 最后修改: 2006-5-11
* 修改人:redriver@263.net
*
* 创建日期: 2006-5-11
* 创建人:redriver@263.net
*/
$fileName = $_GET['fileName'];
if (!file_exists($fileName))
{
exit('文件' . $fileName . '不存在。');
}
$fileSize = filesize($fileName);
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Content-Length: " . $fileSize);
Header("Content-Disposition: attachment; filename=" . $fileName);
$fp = fopen($fileName, "r");
$bufferSize = 1024;
$curPos = 0;
while((!feof($fp)) && (($fileSize - $curPos) > $bufferSize))
{
$buffer = fread($fp, $bufferSize);
print($buffer);
$curPos += $bufferSize;
}
$buffer = fread($fp, $fileSize - $curPos);
print($buffer);
?>