updated file upload logic