Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/dialog.ts>openFile

A JavaScript extension package for building strong and modern applications.
Latest
function openFile
Re-export
import { openFile } from "https://deno.land/x/ayonli_jsext@v0.9.72/dialog.ts";

Opens the file picker dialog and selects a file to open.

Examples

Example 1

// default usage
import { openFile } from "@ayonli/jsext/dialog";

const file = await openFile();

if (file) {
    console.log(`You selected: ${file.name}`);
}

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/"));
}

Returns

Promise<File | null>

Opens the file picker dialog and selects multiple files to open.

Parameters

options: FileDialogOptions & { multiple: true; }

Returns

Promise<File[]>

Opens the directory picker dialog and selects all its files.

Parameters

options: Pick<FileDialogOptions, "title"> & { directory: true; }

Returns

Promise<File[]>