Home >Web Front-end >JS Tutorial >Instructions for using the fs.readFile method in node.js_node.js
Method description:
Read file contents asynchronously.
If the top content is not encoded, it will be output in buffer format, such as:
Grammar:
Since this method belongs to the fs module, the fs module needs to be introduced before use (var fs= require(“fs”) )
Receive parameters:
filename file path
options option object, including encoding, encoding format, this item is optional.
callback Callback, passing 2 parameters: exception err and file content data
Example: