import { openFile } from "https://deno.land/x/ayonli_jsext@v0.9.72/dialog/index.ts";
Opens the file picker dialog and selects a file to open.
Examples
Example 1
Example 1
// default usage
import { openFile } from "@ayonli/jsext/dialog";
const file = await openFile();
if (file) {
console.log(`You selected: ${file.name}`);
}
Example 2
Example 2
// filter by MIME type
import { openFile } from "@ayonli/jsext/dialog";
const file = await openFile({ type: "image/*" });
if (file) {
console.log(`You selected: ${file.name}`);
console.assert(file.type.startsWith("image/"));
}
Parameters
optional
options: FileDialogOptionsOpens the file picker dialog and selects multiple files to open.
Parameters
options: FileDialogOptions & { multiple: true; }
Opens the directory picker dialog and selects all its files.
Parameters
options: Pick<FileDialogOptions, "title"> & { directory: true; }