refactoring upload photo logics