Chat Upload
Chat-style message interface with file attachment support. Attach files to messages before sending.
var uploader = new MultipleUpload(el, {
uploadUrl: '/api/upload',
attachmentMode: true,
autoUpload: true,
onFileAdded: function(task) {
showAttachmentChip(task);
},
onTaskComplete: function(task) {
pendingAttachments.push(task.name);
}
});
sendBtn.addEventListener('click', function() {
sendMessage(input.value, pendingAttachments);
});
Uploading while the user is still typing
In a message composer the file should be on its way before send is pressed, so sending is instant regardless of size. That is autoUpload plus attachmentMode: transfer starts on selection, and the queue renders as compact chips that sit under the input rather than a stacked list that pushes it off screen.
The bookkeeping this creates
Files now reach the server before the message exists, so an abandoned draft leaves uploads with nothing pointing at them. Store to a staging area, associate on send, and sweep what was never claimed — the sweep is the part that gets forgotten until storage fills up.