FileReader - Web APIs | MDN (2024)

Note: This feature is available in Web Workers.

The FileReader interface lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read.

File objects may be obtained from a FileList object returned as a result of a user selecting files using the <input> element, or from a drag and drop operation's DataTransfer object.

FileReader can only access the contents of files that the user has explicitly selected, either using an HTML <input type="file"> element or by drag and drop. It cannot be used to read a file by pathname from the user's file system. To read files on the client's file system by pathname, use the File System Access API. To read server-side files, use fetch(), with CORS permission if reading cross-origin.

Constructor

Instance properties

FileReader.error Read only

A DOMException representing the error that occurred while reading the file.

FileReader.readyState Read only

A number indicating the state of the FileReader. This is one of the following:

Name Value Description
EMPTY 0 No data has been loaded yet.
LOADING 1 Data is currently being loaded.
DONE 2 The entire read request has been completed.
FileReader.result Read only

The file's contents. This property is only valid after the read operation is complete, and the format of the data depends on which of the methods was used to initiate the read operation.

Instance methods

FileReader.abort()

Aborts the read operation. Upon return, the readyState will be DONE.

FileReader.readAsArrayBuffer()

Starts reading the contents of the specified Blob, once finished, the result attribute contains an ArrayBuffer representing the file's data.

FileReader.readAsBinaryString() Deprecated

Starts reading the contents of the specified Blob, once finished, the result attribute contains the raw binary data from the file as a string.

FileReader.readAsDataURL()

Starts reading the contents of the specified Blob, once finished, the result attribute contains a data: URL representing the file's data.

FileReader.readAsText()

Starts reading the contents of the specified Blob, once finished, the result attribute contains the contents of the file as a text string. An optional encoding name can be specified.

Events

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface. Remove the event listeners with removeEventListener(), once FileReader is no longer used, to avoid memory leaks.

abort

Fired when a read has been aborted, for example because the program called FileReader.abort().

error

Fired when the read failed due to an error.

load

Fired when a read has completed successfully.

loadend

Fired when a read has completed, successfully or not.

loadstart

Fired when a read has started.

progress

Fired periodically as data is read.

Specifications

Specification
File API
# APIASynch

Browser compatibility

BCD tables only load in the browser

See also

FileReader - Web APIs | MDN (2024)
Top Articles
US Affordable Rental Housing Policy Either Doesn’t Make Any Sense or Is Working as Intended
How to Type a Bitcoin Symbol in Excel & Google Sheets
Bubble Guppies Who's Gonna Play The Big Bad Wolf Dailymotion
It's Official: Sabrina Carpenter's Bangs Are Taking Over TikTok
Roblox Roguelike
Wordscapes Level 6030
T&G Pallet Liquidation
Www.paystubportal.com/7-11 Login
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Top Hat Trailer Wiring Diagram
Thayer Rasmussen Cause Of Death
Things To Do In Atlanta Tomorrow Night
Housework 2 Jab
Hca Florida Middleburg Emergency Reviews
Mini Handy 2024: Die besten Mini Smartphones | Purdroid.de
Connect U Of M Dearborn
Clear Fork Progress Book
Watch The Lovely Bones Online Free 123Movies
Craigslist Mt Pleasant Sc
Inter-Tech IM-2 Expander/SAMA IM01 Pro
Quadcitiesdaily
Pokemon Unbound Shiny Stone Location
About My Father Showtimes Near Copper Creek 9
Hannaford Weekly Flyer Manchester Nh
Sand Dollar Restaurant Anna Maria Island
Helpers Needed At Once Bug Fables
11526 Lake Ave Cleveland Oh 44102
Pulitzer And Tony Winning Play About A Mathematical Genius Crossword
Truck from Finland, used truck for sale from Finland
4.231 Rounded To The Nearest Hundred
Kaliii - Area Codes Lyrics
Ehome America Coupon Code
A Grade Ahead Reviews the Book vs. The Movie: Cloudy with a Chance of Meatballs - A Grade Ahead Blog
Kaiju Paradise Crafting Recipes
Murphy Funeral Home & Florist Inc. Obituaries
Drabcoplex Fishing Lure
Sinai Sdn 2023
Pay Entergy Bill
This 85-year-old mom co-signed her daughter's student loan years ago. Now she fears the lender may take her house
Download Diablo 2 From Blizzard
Janaki Kalaganaledu Serial Today Episode Written Update
All-New Webkinz FAQ | WKN: Webkinz Newz
Locate phone number
Tfn Powerschool
Dr Mayy Deadrick Paradise Valley
Holzer Athena Portal
St Anthony Hospital Crown Point Visiting Hours
UNC Charlotte Admission Requirements
Mit diesen geheimen Codes verständigen sich Crew-Mitglieder
Tanger Outlets Sevierville Directory Map
The Love Life Of Kelsey Asbille: A Comprehensive Guide To Her Relationships
Latest Posts
Article information

Author: Kareem Mueller DO

Last Updated:

Views: 5409

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Kareem Mueller DO

Birthday: 1997-01-04

Address: Apt. 156 12935 Runolfsdottir Mission, Greenfort, MN 74384-6749

Phone: +16704982844747

Job: Corporate Administration Planner

Hobby: Mountain biking, Jewelry making, Stone skipping, Lacemaking, Knife making, Scrapbooking, Letterboxing

Introduction: My name is Kareem Mueller DO, I am a vivacious, super, thoughtful, excited, handsome, beautiful, combative person who loves writing and wants to share my knowledge and understanding with you.