编辑文件-纯js [英] Edit file - pure js

查看:46
本文介绍了编辑文件-纯js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在纯js中编辑文件(无节点)? 我得到一个带有输入字段的文件,并按如下方式读取其文本:

How do I edit a file in pure js (without node)? I get a file with an input field and I read its text like this:

var fileReader = new FileReader();
fileReader.readAsText(file);

fileReader.onload = function () {
    alert(this.result);
}

所以,很简单.我试图在网上寻找如何使用fileWriter的方法,但没有成功. 我只需要编辑该文件中的文本并将其保存,该怎么办?

So, pretty straight forward. I tried to look on the net how to use a fileWriter but with no success. I just need to edit the text inside that file and save it, how can I do?

推荐答案

您不能在浏览器中写入文件,而必须使用node.

You can't write files in a browser, you'll have to use node.

这篇关于编辑文件-纯js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆