It may not correctly work as it is untested and as I have failed to understand its logic.
Attach a file by drag & drop or click to upload