Filesystem

openfilesdialog

Opens a native file picker that can return multiple selected files.

Syntax

openfilesdialog(options?: DialogOptions): table | nil

Arguments

NameTypeDescription
options?DialogOptionsOptional settings table that controls how the operation behaves.

Returns

NameTypeDescription
filestable | nilArray table of selected file metadata, or nil when cancelled.

Description

Opens a native file picker that can return multiple selected files.

Call it with 1 parameter(s): options. The argument table explains which values are required and which ones only refine the behavior.

It returns files (table | nil). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Let the user select multiple files with an extension filter.

local files = openfilesdialog({
    title = "Choose source files",
    defaultPath = "workspace",
    extensionFilter = { "lua", "luau", "txt" },
})

if files then
    for _, file in ipairs(files) do
        print(file)
    end
end

Types

DialogOptions

Configures the native file or folder selection dialog.

title? string Sets the dialog window title.defaultPath? string Selects the directory shown when the dialog opens.extensionFilter? {string} Limits selectable files to the listed extensions, with or without a leading dot.suggestedName? string Provides the initial file name in save dialogs.defaultExtension? string Sets the extension used when the entered file name has none.