In this episode, we tidy up what happens after a file upload finishes. First, we look at what occurs if we don't clean things up — the UI gets stuck with the progress bar at 100% and doesn't reflect the new file, which is not ideal.
To fix this, we update our success handler so that after a successful upload, the file list gets refreshed. If you’re using Inertia, we show how to use the router to reload just the files prop (and not the whole page!), making everything seamless for the user. We even preserve the user’s scroll position so nothing jumps around unexpectedly.
Next, we focus on resetting state after an upload, so our upload form and progress bar clear out properly. We create an initial state object and introduce a convenient reset
method to restore everything to its original state in one go — much neater than clearing every property individually. This makes things simpler not only for uploads, but also sets us up nicely for future features like canceling an upload.
By the end, uploads feel much smoother: file lists update instantly, the UI resets ready for the next upload, and the overall experience is more polished. Super useful tweaks! 🎉