我的问题是 - 什么是检测下载是否完成的最佳方法, 因为之后我想更新数据库。检查下载是否完成
我尝试了一些来自php manuel的代码,但它对我没有多大帮助。
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
}
感谢进阶,理查德
IM找到了一个很好的解决方案来实现纯PHP: http://bytes.com/topic/php/answers/551302-how-detect-if-file-download-completed-取消 – StefanoCudini