deleting a file after user download it
unlink($filename);
This will delete the file.
It needs to be combined with ignore_user_abort()
Docs so that the unlink
is still executed even the user canceled the download.
ignore_user_abort(true);
...
unlink($f);
I always use the following solution, using register_shutdown_function:
register_shutdown_function('unlink', $file);