简体   繁体   中英

Save file with different extension javascript

So, I'm currently saving a file with .TXT extension, but I would like to change it to save a .INI extension.

I'm using this code on my js to save a .TXT file:

blob = new Blob([file], {type: "text/plain;charset=utf-8"})
        saveAs(blob, name)

This .INI extension can be edited with notepad, so I would like to know if it is possible to download a file with .INI extension.

Thanks

Because you haven't posted the implementation for the saveAs function, there really is no way to know how it works. I would try the following:

var name = 'myfile.ini';
blob = new Blob([file], {type: "text/plain;charset=utf-8"});
saveAs(blob, name);

That's the best I can say without knowing the library that you're using and how it's implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM