finish upload function