Added MIME type detection and setting for uploaded files