如何使用JavaScript读取和写入文件 [英] How to read and write into file using JavaScript
问题描述
然而JavaScript本身确实允许这样做;它可以完成与服务器端JavaScript。
编辑:这个链接是现在被Oracle移动的Sun文档。
为了跟上这个时代,FileSystem类的node.js文档: a href =http://nodejs.org/docs/latest/api/fs.html =noreferrer> http://nodejs.org/docs/latest/api/fs.html
编辑(2):您现在可以使用HTML5读取客户端文件: http://www.html5rocks.com/en/tutorials/file/dndfiles/
Can anybody give the sample code to read and write the file using JavaScript?
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)
However javascript per se does allow this; it can be done with server side javascript.
See this documentation on the Javascript File class
Edit: That link was to the Sun docs that now have been moved by Oracle.
To keep up with the times here's the node.js documentation for the FileSystem class: 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/
这篇关于如何使用JavaScript读取和写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!