FileReader: FileReader() constructor
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("File API")}}{{AvailableInWorkers}}
The **FileReader()** constructor creates a new FileReader.
For details about how to use FileReader, see Using files from web applications.
Syntax
js-nolint
new FileReader()Parameters
None.
Examples
The following code snippet shows creation of a {{domxref("FileReader")}} object using the FileReader() constructor and subsequent usage of the object:
js
function printFile(file) {
const reader = new FileReader();
reader.onload = (evt) => {
console.log(evt.target.result);
};
reader.readAsText(file);
}Specifications
{{Specifications}}
Browser compatibility
{{Compat}}