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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54a25-43da7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54a25-43da7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?