Updated file upload logic