Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The getFileHandle() method of the FileSystemDirectoryHandle interface returns a FileSystemFileHandle for a file with the specified name, within the directory the method is called.
A string representing the FileSystemHandle.name of the file you wish to retrieve.
options OptionalAn object with the following properties:
create OptionalA Boolean. Default false. When set to true if the file is not found, one with the specified name will be created and returned.
A Promise which resolves with a FileSystemFileHandle.
Thrown if the PermissionStatus.state for the handle is not 'granted' in readwrite mode if the create option is set to true or in read mode if the create option is set to false.
TypeErrorThrown if the name specified is not a valid string or contains characters that would interfere with the native file system.
TypeMismatchError DOMExceptionThrown if the named entry is a directory and not a file.
NotFoundError DOMExceptionThrown if the current entry is not found or if the file doesn't exist and the create option is set to false.
The following example returns a file handle with the specified name, if the file does not exist it is created.
| File System # api-filesystemdirectoryhandle-getfilehandle |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Oct 20, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.