Solution: reduced code duplication by introducing local variables and new function trigger_events
Attach a file by drag & drop or click to upload