FilePicker
A file input field wrapped into a Button. Clicking the button opens a browser file picker window. When files are chosen, badge appears showing amount of files. Hovering the button shows a tooltip with file names.
By default, only a single file is allowed.
let fileField = new FilePicker({
fileFieldConfig : {
multiple : true,
accept : "image/*"
},
buttonConfig : {
text : 'Pick file...'
},
onChange({ files }) {
// Do cool things
}
});
//<code-header>
fiddle.title = 'File picker';
//</code-header>
new FilePicker({
appendTo : targetElement,
fileFieldConfig : {
multiple : true,
accept : 'image/*'
},
buttonConfig : {
text : 'Pick multiple images',
rendition : 'filled'
}
});
new FilePicker({
appendTo : targetElement,
buttonConfig : {
text : 'Pick single file of any type',
rendition : 'filled'
},
style : 'margin-inline-start: 2em;'
});Configs
95
Configs
95Common
Misc
The name of the property to set when a single value is to be applied to this FilePicker. Such as when used
in a grid WidgetColumn, this is the property to which the column's field is applied.
Other
Wrapper button config object. See Button for list of available configs.
Underlying field config object. See FileField for list of available configs.
Set to false to hide the badge indicating the number of files selected
CSS
DOM
Float & align
Layout
misc
Scrolling
Properties
84
Properties
84Class hierarchy
Other
Set to false to hide the badge indicating the number of files selected
CSS
DOM
Layout
Misc
Widget hierarchy
Functions
68
Functions
68Other
Clears field
Configuration
Events
Misc
Widget hierarchy
Events
18
Events
18Fires after user closes file picker dialog.
// Adding a listener using the "on" method
filePicker.on('change', ({ files }) => {
});| Parameter | Type | Description |
|---|---|---|
files | FileList | List of picked files |
Fires when field is cleared with clear method
// Adding a listener using the "on" method
filePicker.on('clear', ({ }) => {
});Event handlers
18
Event handlers
18Called after user closes file picker dialog.
new FilePicker({
onChange({ files }) {
}
});| Parameter | Type | Description |
|---|---|---|
files | FileList | List of picked files |