How to run a code when a file is attached to a doctype

Hi Everyone,

I wonder, if there is any way to run a code when a file is attached to the doctype.

Regards
Ruchin Sharma