selectFiles([settings])
Opens a selection dialog that allows to select one or multiple files. The settings object can be used to add a prompt text at the top of the dialog, to restrict the selection to certain file types and to set the dialog’s starting folder.
Type: function
Parameter(s):
- settings {Object} Optional:
A settings object to control the function’s behavior.
- settings.prompt {String} Optional:
The prompt text at the top of the file selection dialog. Default:
""
(no prompt) - settings.filter {} Optional:
String or an array containing strings of file endings to include in the dialog. Default:
""
(include all) - settings.folder {} Optional:
Folder or a folder path string defining the start location of the dialog. Default: most recent dialog folder or main user folder.
Returns:
-
{Array}:
Array of the selected file(s). If the user cancels, an empty array will be returned.
Example(s):
Open file selection dialog with a prompt text
selectFiles({prompt: "Please select your files."});
Open selection dialog starting at the user's desktop, allowing to only select PNG or JPEG files
selectFiles({folder: "~/Desktop/", filter: ["jpeg", "jpg", "png"]});