Javascript:创建并保存文件 [英] Javascript: Create and save file
问题描述
基本上我想知道该功能中的内容:
saveFile:function(data)
{
}
函数在数据中进行访问,用户选择一个位置来保存文件,并在该位置创建一个文件。
感谢提前。
编辑:
如果这有帮助,也可以使用HTML。
github上的这个项目看起来很有希望:
https://github.com/eligrey/FileSaver.js
FileSaver.js实现W3C saveAs()
另请参阅这里的演示:
>http://eligrey.com/demos/FileSaver.js/
I have data that I want to write to a file, and open a file dialog for the user to choose where to save the file. It would be great if it worked in all browsers, but it has to work in Chrome. I want to do this all client-side.
Basically I want to know what to put in this function:
saveFile: function(data)
{
}
Where the function takes in data, has the user select a location to save the file, and creates a file in that location with that data.
Thanks in advance.
EDIT: Using HTML is fine too, if that helps.
This project on github looks promising:
https://github.com/eligrey/FileSaver.js
FileSaver.js implements the W3C saveAs() FileSaver interface in browsers that do not natively support it.
Also have a look at the demo here:
http://eligrey.com/demos/FileSaver.js/
这篇关于Javascript:创建并保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!