Downloading txt,png files with a browser will be opened directly.

downloading txt,png files with a browser will be opened directly, but not even forced downloads.

<a href="http://test.cdn.sunmi.com/FILE/5c0775ff484be.txt" download=".txt" target="_blank">2</a>

<button onclick="download()">1</button>
function download () {
    try{ 
        var elemIF = document.createElement("iframe");   
            elemIF.src = "https://img.codeshelper.com/upload/img/2022/01/12/kqmsefsmuuq2516.jpg";   
            document.body.appendChild(elemIF);   
    }catch(e){ 
        console.info("e", e) 
    }   
}

the above results are that the browser directly opens the corresponding file and cannot be forced to download it. Which boss will analyze the wave and give a plan? thank you very much

Jan.12,2022

in the header processing of the file itself, set the picture header to

when uploading the picture.
Content-Type: application/octet-stream

use FileSaver.js

Menu