let headImgSave = function (image){ let binaryData = Buffer.from(image,"base64").toString("binary"); let openid = Math.random().toString(26).substr(2,8); let imgPath = path.join(__dirname, `upload`); let headImg = `${imgPath}/${openid}.jpg`; fs.writeFile(headImg,binaryData,'binary',function (err){ if(err) throw err; }) }