Ask for help, how to convert base64 into pictures and upload them locally with node and display them at the front desk?

problem description: the pc side takes photos to get the base64 file, wants to upload this file to the local node service, and reads the photo file when querying

Jan.11,2022

    var formData = new FormData();
    var btn = document.getElementById("uploadImg");//
    var file = btn.files[0];
    formData.append('file',file);//formData
    var reader = new FileReader();//
    reader.onloadend = function () {       
        var dataURL = reader.result;
        var img = new Image();
        img.src = dataURL; 
        //  DOM 
        // ...
    };
    reader.readAsDataURL(file);

1. If the photo is obtained by base64, then send it to the server directly with post, and the server will save it
2. Directly assign a value to the src of img when taking it

<img src="data:image/jpeg;base64,xxxxxxxx"
Menu