File upload logic