How to detect when a user has successfully finished downloading a file in php

旧巷老猫 提交于 2019-11-27 08:45:33
Treb

Handle the download in a seperate php script (better do a little more than just readfile($file);, you can also provide the ability to resume downloads like in this question). Then in this script, when you read the last block and send it, you know that all the file was sent. This is not the same as knowing that all was received, but it should be enough for most scenarios.

What Treb said, but I should add that you can check if the client is still listening during download with connection_status().

Don't forget to flush() after you've written data to the client, it helps in detecting if the connection is still up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!