State Persistence (localStorage)
Save and restore the completed files list across page reloads.
(function() {
var uploader = new MultipleUpload('#demo', {
uploadUrl: '/api/upload',
multiple: true,
persistState: true,
persistKey: 'demo-persist'
});
document.getElementById('clear-state').addEventListener('click', function() {
uploader.clearPersistedState();
uploader.reset();
});
document.getElementById('reload-btn').addEventListener('click', function() {
location.reload();
});
})();
Surviving a reload
persistState defaults to false. Turned on, in-flight uploads are written to storage so a reload, a crash or a closed tab does not lose the queue. persistAdapter defaults to 'localStorage'; IndexedDB is the other option and the one to choose when you also want the file bytes kept.
What survives depends on the adapter
localStorage can hold the queue's bookkeeping — which files, how far each got — but not the File objects themselves, so the user has to re-pick the files before the resume continues. IndexedDB can store the blobs too, which is what makes resume genuinely zero-click. That is the whole difference between the two, and it is worth deciding deliberately.