upload and write to db