Redirect on Complete
Redirect the user to another page after all uploads complete using the onComplete callback. This example shows a countdown before redirect.
new MultipleUpload(document.getElementById('demo-redirect'), {
uploadUrl: '/api/upload',
multiple: true,
onComplete: function(files) {
var msg = document.getElementById('redirect-msg');
msg.style.display = '';
var seconds = 3;
msg.textContent = files.length + ' file(s) uploaded! Redirecting in ' + seconds + 's...';
var timer = setInterval(function() {
seconds--;
if (seconds <= 0) {
clearInterval(timer);
msg.textContent = 'Redirect cancelled (demo mode).';
// In production: window.location.href = '/thank-you';
} else {
msg.textContent = files.length + ' file(s) uploaded! Redirecting in ' + seconds + 's...';
}
}, 1000);
}
});
Moving on when the queue drains
onComplete is the natural place to advance: navigate to the record, close the dialog, refresh the list. It fires once everything in the queue has settled.
Settled includes failed
The queue completes when nothing is left in flight, which includes files that failed and exhausted their retries. Redirecting unconditionally takes the user away from the only screen that could have told them two attachments did not upload — check the state before navigating.