File upload refactoring.