Constructs a File with bytes and metadata; does not read arbitrary disk paths.

Formal Syntax & Structure

javascript syntaxjavascript
new File(parts, name, options)

Parameters & Attributes

NameTypeDescription
partsarrayFile content parts.
namestringFile name.
optionsobjectOptional type and lastModified.

Return Value

File

Constructs a File with bytes and metadata; does not read arbitrary disk paths.

Working Example

Example Snippetjavascript
(async () => {const f=new File(["abc"],"notes.txt",{lastModified:1000,type:"text/plain"});console.log(f.name,f.size,f.lastModified);})()
JavaScript Reference