complete the uploading function