1. Select the image to the Node server

Uni – app code

uni.chooseImage({ success: (res) => { let tempFilePaths = res.tempFilePaths; TempFilepaths ((item) = bb0 {uni. UploadFile ({url: ", // fileType: ", // Name: 'file', success: (uploadFileRes) => {}}); }}}));

Node Service Code

const path = require("path"); // import path module const multer = require("multer"); // import a multer const fs = require("fs"); // import file operation module const util = require(".. /public/util"); const upload = multer({ dest: "tmp/" }); let express = require("express"); let router = express.Router(); router.post("/upload", upload.single("file"), function (req, res) { let imgFile = req.file; Var TMP = imgfile.path; var TMP = imgfile.path; // get temporary resource let ext = path.extName (imgfile.originalName); Let newName =util.getNowFormatDate('-','-')+ "-"+new Date().getTime() + Math.round(Math.random() * 10000) + ext; Let newPath = "/public/images/" + newName; In advance, create an images folder !!!! under the current folder let fileData = fs.readFileSync(tmp); Let filePath = path.join(__dirname, '.. '); let filePath = path.join(__dirname, '.. '); '+newPath); fs.writeFileSync(filePath, fileData); // Rewrite the image file to the specified folder res.send(newPath); // respond to client after uploading successfully}); router.get('/public/images/*', function (req, res) { let newPath = ".." +req.url; let filePath = path.join(__dirname,newPath); res.sendFile(filePath); }) module.exports = router;

2. Select images to cloud storage

uni.chooseImage({ success: (res) => { let tempFilePaths = res.tempFilePaths; tempFilePaths.forEach((item) => { uniCloud.uploadFile({ filePath: item, cloudPath: 'item.jpg', success(res) { }, fail(res) { }, complete() {} }); }}}));