Reverted the original patch and changed it to the obvious simple solution provided by @Neilpang.
Attach a file by drag & drop or click to upload