implementing the upload logic