File upload fixes to solve garbled attachments