我的問題是 - 什麼是檢測下載是否完成的最佳方法, 因爲之後我想更新數據庫。檢查下載是否完成
我嘗試了一些來自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