Modified file upload logic.