upload.js refactor