Move sample format dependent code to a separate function.
Attach a file by drag & drop or click to upload