In this episode, we're diving into actually sending file chunks from the client to the server — the first big step in chunked uploads! We're using the UpChunk library to split files into chunks and post each one to a backend endpoint. Most of this episode is about setting up that whole process on the client-side, even though we won't be handling the chunks just yet on the backend.
We'll walk through integrating UpChunk with Livewire and Alpine.js, pointing out a few tricky parts with reactivity and endpoints. To keep things simple and get things moving, we create a dummy backend route—so we're just getting the files to send, not worry about actually processing them yet.
We also bump into a classic Laravel gotcha: the CSRF (Cross-Site Request Forgery) token. Because UpChunk uses a plain XHR request, we need to manually attach the CSRF token in the headers or Laravel will block our requests. You'll see how to add the token to make the upload work safely.
Towards the end, we mess around with the chunk size setting, showing how to adjust the upload behavior for larger or smaller transfers. Finally, you'll see the uploads happening in chunks in your browser's network tab, setting the stage for wiring up the real backend next!
So, after this video, you'll have the groundwork laid for chunked uploads: files are getting split, sent, and received by your Laravel app (even if it's just a dummy endpoint for now). Next up, we'll look at what to actually do with those chunks on the server side.