I have the feeling this should be quite basic, but I've failed to find a solution anywhere.
I'm working on an application that sends out an email to admins when a file is downloaded. Currently the email is sent out when a download begins, but I need to change this so that it only sends when the download is completed.
I suspect something like PHP's register_shutdown_function might be what I need, but according to the PHP manual shutdown functions are now called before the request is completed. Which leaves me a bit stumped.
For what it's worth, the function that currently handles downloads outputs them like this:
readfile($path);
exit;
The site in question is pretty large and complicated, so ideally I'd like to make as little change to the current code as possible. Any advice on how to solve this problem would be very much appreciated! Thanks.