File Access

The File API gives web applications an access to the filesystem-level information about the files that the user decides to share with the application, i.e. size, MIME type, modification date, content, without sending the file to the server.

API glimpse

fileInputElement.files
Returns a collection of file objects that were selected by the user using <input type="file">DOM element.
file.name
Returns the original name of the file, without the path.
file.size
Returns the file size in bytes.
file.type
Returns the file's MIME type.
file.lastModifiedDate
Returns the file's last modification date.
fileReader.readAsText(file)
Initiates a process of reading the file and encoding its content as text.
fileReader.addEventListener('load', listener)
An event fired when the reading operation has completed successfully. The data read is available via fileReader.result property.

Resources