qds-file-upload selects real browser files and optionally coordinates an application-owned upload handler. It includes a native picker, optional dropzone, named file actions, metadata validation and cancellable progress/error/retry states.
<script type="module" src="/assets/components/file-upload/qds-file-upload.js"></script>
<qds-file-upload label="Diligence attachments" name="attachments" multiple
accept=".pdf,.xlsx,image/*" max-size="10485760" max-files="5"
hint="Choose up to five files, each no larger than 10 MiB."></qds-file-upload>
See the complete interactive demo for selection, forms, transfer, error/retry, readonly/disabled and composition examples.
files: File[] returns a fresh array containing the selected actual File references. Owner assignment is silent. Duplicate references are collapsed; distinct same-name files remain distinct.validity.badInput true. Remove/reselect them or change the constraints; rejected files never reach the handler. Programmatic selections obey the same constraints.accept recognizes extensions, MIME types and MIME wildcards. max-size is bytes per file; max-files is the multiple-selection limit. Zero means unlimited. Single mode always limits the canonical selection to one valid entry.required requires selection independently of transfer completion. Transfer errors do not change the File model. invalid, error-text, setCustomValidity(), checkValidity() and reportValidity() provide native form constraints.disabled prevents interaction and omits submission. readonly preserves selected files for submission while preventing picker/drop, file changes and transfers. Either state cancels requested/running work. Disabled fieldsets are supported independently of the element’s own disabled attribute.name submits each selected File as a repeated FormData entry. form supports an external native form. The browser validates the field before ordinary form submission; manually calling new FormData(form) does not run validation.
checkValidity() leaves focus in place. Native invalid submission and repeated component/form reportValidity() focus the visible chooser while preserving its caption and selected File values. Canceling invalid suppresses native validation focus. The internal picker adds no Tab stop. Error text uses the normal text token with an error-colored border so it remains readable in both themes.
Native reset clears selection and cancels work without input/change events. Browser restoration accepts real File/FormData state, restores queued files silently, and never starts transport automatically. Fake paths and string restore values are ignored.
const uploader = document.querySelector('qds-file-upload');
uploader.addEventListener('change', ({ detail }) => {
console.log(detail.files); // actual File objects, not paths or JSON
});
uploader.uploadHandler = async (file, { signal, onProgress }) => {
// Your transport owns endpoint, authentication, persistence and policy.
const result = await applicationUpload(file, { signal, onProgress });
return result;
};
await uploader.upload();
onProgress(loaded, total = file.size) accepts finite byte counts and clamps progress to 0–100. Before a determinate update, the named native progress is indeterminate.concurrency bounds a positive limit to 1–6; nonpositive/nonfinite values use the default of 2. auto starts newly selected accepted files. Adding another file does not retry previous errors or cancellations; use explicit retry/upload actions. Assigning files or a handler, reconnecting, or restoring browser state does not initiate transport.upload(id?) requests all eligible files or one stable task ID and resolves when those attempts settle, including errors/cancellation/removal. It does not reject on an individual transfer failure; inspect task status/events.cancel(id?) cancels requested/running attempts. retry(id) starts a fresh attempt for an error/cancelled task. Completion is emitted once for the current attempt. Completed files are not sent again.tasks returns frozen task snapshots with stable id, actual file, status, progress, error, rejection and application result. Statuses are queued, uploading, completed, error, cancelled and rejected. Metadata rejection is separate from transfer state: relaxing a constraint restores a completed task’s completed status.input and change, with { component, files, value }. Owner writes and native reset/restore are silent. Transfer actions do not emit selection changes.upload-start, upload-progress, upload-complete, upload-error and upload-cancel, each with { component, task }.qds-validity-change reports native validity transitions.aria-label, copied same-root text from aria-labelledby, or the visible label. All actions are at least 44px; same-name file actions include an ordinal.focus() targets the chooser; choose() opens its native file picker when editable.Generated QdsFileUploadComponent supports File[] reactive forms and direct bindings while preserving actual File identity. It exposes typed transport/selection events and public choose/upload/cancel/retry/removeFile/clear/focus/validation methods. Task snapshots remain readonly native state. Documents uses these generated bindings to prepare local diligence evidence for an opportunity, show progress/error/cancel/retry, and display a completed local attachment with an opportunity link. Pending files clear on context changes; attachments reset on navigation/reload. File contents stay in the browser.