- FileReader.readAsArrayBuffer(): Reads the contents of the specified input file. The result attribute contains an ArrayBuffer representing the file’s data.
- FileReader.readAsBinaryString(): Reads the contents of the specified input file. The result attribute contains the raw binary data from the file as a string.
- FileReader.readAsDataURL(): Reads the contents of the specified input file. The result attribute contains a URL representing the file’s data.
- FileReader.readAsText(): Reads the contents of the specified input file. The result attribute contains the contents of the file as a text string. This method can take encoding version as the second argument(if required). The default encoding is UTF-8.
In this case we are using FileReader.readAsText() method to read local .txt file.
This code prints the content of the input file exactly the same as is there in the input file.
- How to read and write JSON file using Node.js ?
- How to read a file line by line using node.js ?
- Local File Inclusion (LFI)
- How to Read a File Line by Line to String in Golang?
- Java Program to Make a File Read-Only
- How to find record using any key-value pair information of record in your local/custom database using Node.js ?
- Text Animation with changing the color of the text using HTML & CSS
- How to create long shadow of text without using text-shadow in HTML and CSS ?
- How to delete text from file using preg_replace() function in PHP ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.