refactor upload js