I upload the avatar on the client side, and the picture is uploaded to the server and saved in a fixed folder. Now how do I read this picture on the client side?
the running environment is the backend is node koa
related codes
exports.editcover = async (ctx) => {
const {
userId,
imgfile
} = ctx.request.body
var base64Data = imgfile.replace(/^data:image\/\w+;base64,/, "");
var dataBuffer = new Buffer(base64Data, "base64");
let name = new Date().getTime().toString() + OrderHelper.generateRondom(10).toString();
let url = "./upload/"+name+".png"
fs.writeFile(url, dataBuffer, function(err) {
if(err){
console.log("");
}else{
console.log("");
console.log(url);//upload
}
});
}
I want to know how to generate a picture link and save it to the database. After the client can access the file in upload on my server through the picture link, please, my novice front end, if the description is wrong, please forgive me.