refactory upload controller