added better error handling for fileupload