File upload field
Upload a single file, bound to a column reference, an attachment, or an external storage endpoint.
The File upload field captures a single file. Where the file is stored depends on the binding, list attachment, document library, or a configured external endpoint. Multi-file scenarios use Attachments or Document Library.
Common properties
| Property | Description |
|---|---|
labelstring default: Upload file | Visible label. |
descriptionstring | Helper text. |
requiredboolean default: false | Marks the field required, a file must be chosen before save. |
readOnlyboolean default: false | Disables the picker, any existing file is still shown. |
Type-specific properties
| Property | Description |
|---|---|
acceptstring default: */* | Accepted MIME types / extensions for the file picker, e.g. image/*, .pdf, or a comma-separated list. Passed straight to the input accept attribute. |
targetLibraryUrlstring | Target SharePoint document library URL the uploaded file is written to when bound. Empty uses the form’s default library. |
JavaScript recipes
Read the uploaded file value
const file = f365.field('Attachment').value;
if (!file) {
// nothing chosen yet
}
Require a file before save
f365.events.onValidate((errs) => {
if (!f365.field('Attachment').value) {
errs.add('Attachment', 'Please attach a file before submitting.');
}
});
Clear the picker when another field changes
f365.field('Category').on('change', () => {
f365.field('Attachment').clear();
});
Block save while the field is invalid
f365.events.onBeforeSave(() => {
const { valid, errors } = f365.field('Attachment').validity();
if (!valid) {
void f365.ui.showAlert(errors[0] ?? 'The attached file is not valid.');
return false; // cancels the save, keeps the form open
}
return true;
});
Related
Related articles
- Attachments field
Upload files attached to the SharePoint list item, and print attached photos as pictures in the PDF report.
- Document Library field
Browse and upload files to a SharePoint Document Library, with the folder structure and metadata that brings.