There is a plugin API function register_upload_in_use
register_upload_in_use
For an example on how to use it, see the code in the Chat plugin.