files/en-us/web/api/window/showdirectorypicker/index.md
{{APIRef("File System API")}}{{Securecontext_Header}}{{SeeCompatTable}}
The showDirectoryPicker() method of the
{{domxref("Window")}} interface displays a directory picker which allows the user to
select a directory.
showDirectoryPicker()
showDirectoryPicker(options)
options {{optional_inline}}
id {{optional_inline}}
mode {{optional_inline}}
"read" for read-only access or "readwrite" for read
and write access to the directory.startIn {{optional_inline}}
"desktop", "documents",
"downloads", "music", "pictures", or "videos") to open the dialog in.A {{jsxref("Promise")}} whose fulfillment handler receives a {{domxref('FileSystemDirectoryHandle')}} object.
AbortError {{domxref("DOMException")}}
"granted" in the specified mode.SecurityError {{domxref("DOMException")}}
Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.
This asynchronous function shows a directory picker and returns a {{domxref('FileSystemDirectoryHandle')}} once selected.
async function getDir() {
const dirHandle = await window.showDirectoryPicker();
// run code for dirHandle
}
{{Specifications}}
{{Compat}}