uploading logic