Inline Upload
Embed an uploader inline within a text editor toolbar. Attach files directly while composing content.
var uploader = new MultipleUpload(el, {
uploadUrl: '/api/upload',
autoUpload: true,
onTaskComplete: function(task) {
// Add attachment chip to the editor
var chip = document.createElement('span');
chip.className = 'attachment-chip';
chip.textContent = task.name;
attachmentArea.appendChild(chip);
}
});
// Toolbar button triggers file dialog
attachBtn.addEventListener('click', function() {
uploader.openFileDialog();
});
An uploader inside a form
The uploader sits alongside the other fields and transfers in the background, so pressing submit never waits on bytes. With hiddenFieldId the completed GUIDs are kept in a hidden input, and the form posts references instead of file content.
Guard the submit while uploads are running
Nothing stops a user submitting mid-upload, and the form would then post a partial list. Disable submit until the queue is idle, or check the state in the handler — a record saved without the attachment the user believed they added is a bug they will not notice until much later.