检测下载是否完成的最佳方法是什么,因为之后我想更新数据库.
我尝试了PHP手册中的一些代码,但它对我没有太大作用:
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=$filename");
// buffered read not using readfile($file);
if ($fp = fopen($bestand, 'rb')) {
while (!feof($fp)) {
$buf = fread($fp, 4096);
echo $buf;
$bytesSent += strlen($buf); /* We know how many bytes were sent to the user */
}
}
if ($bytesSent == filesize($fp)) {
//do something with db
}