The FileReader.onload property contains an event handler executed when the load event is fired, when content read with readAsArrayBuffer, readAsBinaryString, readAsDataURL or readAsText is available.
Example
// Callback from a <input type="file" onchange="onChange(event)">
function onChange(event) {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = function(e) {
// The file's text will be printed here
console.log(e.target.result)
};
reader.readAsText(file);
}
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onload
|
Chrome
Full support 7 |
Edge
Full support 12 |
Firefox
Full support 3.6 |
IE
Full support 10 |
Opera
Full support 11 |
Safari
Full support 6 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 32 |
Opera Android
Full support 11 |
Safari iOS
Full support 6.1 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
FileReader.onload by Mozilla Contributors is licensed under CC-BY-SA 2.5.