finish the upload function