File objects and file metadata
Quick answer
A File extends Blob with a name and modification timestamp. Browser file input exposes user-selected File objects rather than arbitrary filesystem access.
How it works
Construct a local example with new File(parts,name,{type,lastModified}). name, size, type and lastModified describe the object. For a real file input, input.files is a FileList; check its length before reading an item. File names and declared types are untrusted metadata; validate size, structure and authorization at the receiving boundary.
Local examples
Run in a fresh browser document. Uses synthetic local data; actual ByteMind editor support is unverified.
(async () => {const f=new File(["abc"],"notes.txt",{lastModified:1000,type:"text/plain"});console.log(f.name,f.size,f.lastModified);})()Expected console output:
notes.txt 3 1000Explicit timestamp makes the example deterministic.
Run in a fresh browser document. Uses synthetic local data; actual ByteMind editor support is unverified.
(async () => {const f=new File(["hello"],"x.txt");console.log(f instanceof Blob,await f.text());})()Expected console output:
true helloFile inherits Blob behavior.
Common mistakes
An accept attribute is a selection hint, not a security validator. Never infer a real local path from the File name.
Practice
Create a synthetic text file and return only its name and size; explain which fields still need server-side verification.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
File objects and file metadata — Knowledge Check
Apply the concept and reason about local example output.
What does a File inherit from?
Which property describes file modification time in milliseconds since the epoch?
Is an accepted extension sufficient proof of actual file content?
What is the expected console output of File objects and file metadata example 1?
(async () => {const f=new File(["abc"],"notes.txt",{lastModified:1000,type:"text/plain"});console.log(f.name,f.size,f.lastModified);})()What is the expected console output of File objects and file metadata example 2?
(async () => {const f=new File(["hello"],"x.txt");console.log(f instanceof Blob,await f.text());})()