restructure upload.js