Download base64 pictures in the mobile browser is the .bin file

I want to click the button to save a QR code picture in which src is base64 to the phone. I find that it can be saved normally by clicking on the PC, but when I click on the phone, I find that it saves a .bin file

.

clipboard.png

is there any solution to this problem, bosses?

the following is the code

  qrcodeBut() {
    // base64
    this.domArr = []
    var dom = document.getElementById("qrcodeBut")
    this.domArr.push(dom)
    console.log(this.domArr)
    this.domArr.push(this.domArr[0].children[0].children)
    console.log(this.domArr)
    var src = this.domArr[1][0].src
    console.log(src)

    let aLink = document.createElement("a");

    let blob = this.base64ToBlob(src); //new Blob([content]);
    aLink.download = "fileName";
    aLink.href = URL.createObjectURL(blob);
    aLink.click()

  }
Sep.30,2021

isn't the picture saved by pressing the long button on the mobile phone.


solve the problem


you can use canvas to convert it to png
canvas.toDataURL ("image/png")

Menu