JavaScripture
Contribute via GitHub Feedback

JavaScript File : Blob

File is a Blob that represents a file from the filesystem. You can get Files from the HTMLInputElement.files property or the DataTransferItem.getAsFile() method. Use FileReader to read the contents of a File.

Constructors

new File(fileParts : Array, name : String, [filePropertyBag : Object]) : File
filePropertyBag : {
typeStringA valid mime type such as 'text/plain'
endingsStringMust be either 'transparent' or 'native'
}

Creates a new File. The elements of fileParts must be of the types ArrayBuffer, ArrayBufferView, Blob, or String. If ending is set to 'native', the line endings in the file will be converted to the system line endings, such as '\r\n' for Windows or '\n' for Mac.

Example:

Run

Results:

 

Instance Properties

lastModifiedDate : Date  

The last time the file was modified.

Example:

Run

Results:

 

name : String  

The name of the file.

Example:

Run

Results: