Refactored file upload validation