Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

javascript - 如何使用JavaScript读写文件?(How to read and write into file using JavaScript?)

有人可以提供一些示例代码来使用JavaScript读写文件吗?

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For completeness, the OP does not state he is looking to do this in a browser (if he is, as has been stated, it is generally not possible)

(为了完整起见,OP并未声明他正在浏览器中进行此操作(如前所述,如果不可能,通常是不可能的))

However javascript per se does allow this;

(但是javascript本身允许这样做;)

it can be done with server side javascript.

(可以使用服务器端javascript来完成。)

See this documentation on the Javascript File class

( 请参阅 Javascript File类上的文档 )

Edit : That link was to the Sun docs that now have been moved by Oracle.

(编辑 :该链接指向Oracle现在已移动的Sun文档。)

To keep up with the times here's the node.js documentation for the FileSystem class: http://nodejs.org/docs/latest/api/fs.html

(为了与时俱进,这里是FileSystem类的node.js文档: http : //nodejs.org/docs/latest/api/fs.html)

Edit(2) : You can read files client side now with HTML5: http://www.html5rocks.com/en/tutorials/file/dndfiles/

(Edit(2) :您现在可以使用HTML5在客户端读取文件: http : //www.html5rocks.com/zh-CN/tutorials/file/dndfiles/)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...