Refactor upload-photos.js