upload logic