Appearance
Function: showFileUpload()
ts
function showFileUpload(ctx: Context, options: ShowFileUploadOptions): Promise<MwFile[] | null>;Defined in: src/file/getMwFile.tsx:224
Experimental
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
options | ShowFileUploadOptions | Options to configure the file upload dialog. |
Returns
Promise<MwFile[] | null>
An array of MwFile objects, or null if the user cancels.
Deprecated
Use showUI.fileUpload instead.
Display a file upload dialog and return the selected files.
Warning
Be cautious with the validate function when handling large Excel files. Reading large files can block the UI. Keep validations fast.
Example
ts
const options: ShowFileUploadOptions = {
fileUploadTitle: 'Upload Files',
uploadButton: 'Upload',
fileUploadText: 'Please select file to upload.',
minFileLimit: 1,
maxFileLimit: 3,
overlay: true,
overlayProps: {
blur: true,
blurIntensity: 10,
background: 'grey',
},
error: 'You can upload up to 3 files only.',
validate: async (file) => {
if (file.type !== 'application/pdf') {
return {isValid: false, message: 'File type must be PDF.'};
}
return {isValid: true, message: ''};
},
};
const selectedFiles = await showFileUpload(ctx, options);
if (selectedFiles) {
// Process the selected files.
}

