A demo project showing how to upload large files in chunks using CodeIgniter 3 on the backend and resumable.js on the frontend. Instead of sending one big file in a single request, the file is split into small chunks in the browser, uploaded one at a time, and reassembled on the server once every chunk has arrived.
- The upload form (
application/views/large_file_upload_form.php) loads resumable.js and hooks it up to a file input and an "Start Upload" button. - resumable.js splits the selected file into chunks (1 MB each, configurable via
chunkSize) and POSTs them one by one toLargeFileUpload/upload, along with the chunk number, total chunk count, a unique file identifier, and the original filename. application/controllers/LargeFileUpload.phpsaves each chunk to achunks/directory as it arrives.- Once all chunks for a file are present, the controller reassembles them in order into
uploads/, then deletes the temporary chunk files.
- PHP 5.4+ (this is a CodeIgniter 3 application)
- A webserver that can run PHP (Apache, Nginx + PHP-FPM, or
php -S)
- Serve the project root with a PHP-enabled webserver, e.g.:
php -S localhost:8000 - Update
$config['base_url']inapplication/config/config.phpto match the URL you're serving from (it currently points athttp://localhost/frameworks/codeIgniter/). - Visit the site root (or
/large_file_upload) — both route to the upload form. - Choose a file and click Start Upload. Uploaded files land in
uploads/.
This repo is a standard CodeIgniter 3 installation (system/ is unmodified framework code) with one custom feature added on top:
application/controllers/LargeFileUpload.php— handles serving the form and processing uploaded chunks.application/views/large_file_upload_form.php— the upload form and resumable.js wiring.chunks/— created at runtime to hold in-progress chunk files (not checked into version control).uploads/— destination for fully assembled files.
This is a minimal educational example. There is no validation on the incoming filename/identifier fields before they're used to build file paths, so it should be hardened before being used outside of local/learning purposes.