20,360
社区成员
发帖
与我相关
我的任务
分享
...
ignore_user_abort(true);
if ($fd = fopen($filePath, 'rb')) {
session_write_close();
if ($start_offset > 0)
fseek($fd, $start_offset);
while (!feof($fd)) {
print (fread($fd, 16384));
}
fclose($fd);
}
if (connection_aborted()){
...
}
else {
...
}
...
$file = "/tmp/dummy.tar.gz";
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header("Content-Length: ". filesize($file));
readfile($file);
header('Transfer-Encoding:chunked');
ob_flush();
flush();
...
while (!feof($fd)) {
if (connection_aborted()){
fclose($fd);
break;
}
$data = fread($fd, 16384);
if (strlen($data)){
echo dechex(strlen($data)), "\r\n", $data, "\r\n";
}
ob_flush();
flush();
}