FileDrop
Accepts file selections and displays application-managed progress or errors.
When to use
- Collect attachments while the application owns validation and upload.
Examples
Choose a PDF
Loading the example
<k:FileDrop label="Packing slip" accept=".pdf" maxSize="5" add=".onAdd"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.SimpleFile", {
onAdd(event) {
Toast.show(event.getParameter("files")[0].name);
}
}));Manage inspection attachments
This example simulates upload completion locally. Choose a PDF or an image, then remove an entry or retry the failed one.
Loading the example
<k:FileDrop label="Inspection attachments" accept=".pdf,image/*" maxSize="5"
multiple="true" add=".onAdd" remove=".onRemove" retry=".onRetry">
<k:FileItem name="inspection.pdf" size="2048" error="Upload interrupted"/>
</k:FileDrop>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast", "kor/ui/FileItem"], (Controller, Toast, FileItem) => Controller.extend("sample.InspectionFiles", {
onAdd(event) {
const drop = event.getSource();
for (const file of event.getParameter("files")) {
drop.addFile(new FileItem({ name: file.name, size: file.size, progress: 100 }));
}
Toast.show("Files added locally");
},
onRemove(event) {
event.getSource().removeFile(event.getParameter("item")).destroy();
Toast.show("File removed");
},
onRetry(event) {
const item = event.getParameter("item");
item.setError("").setProgress(100);
Toast.show("Simulated upload completed");
}
}));API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
label | string | Field label | |
help | string | Supporting text | |
accept | string | Accepted types or extensions, for example .pdf,image/* | |
maxSize | float | 0 | Maximum size in MB. Zero means unlimited |
multiple | boolean | true | Whether multiple files can be selected |
enabled | boolean | true | Whether file selection is enabled |
Aggregations
| Name | Type | Description |
|---|---|---|
files | FileItem[] | Files and their upload status |
Events
| Name | Type | Description |
|---|---|---|
add | files: object | Accepted files were selected |
remove | item: kor.ui.FileItem | The user requested removal of a file |
retry | item: kor.ui.FileItem | The user requested a retry of a failed upload |
FileItem
A file entry with upload status.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
key | string | File key | |
name | string | Filename | |
size | float | 0 | Size in bytes |
progress | float | 100 | Upload progress as a percentage |
error | string | Upload error message |