Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Large File Upload — CodeIgniter 3

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.

How it works

  1. 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.
  2. resumable.js splits the selected file into chunks (1 MB each, configurable via chunkSize) and POSTs them one by one to LargeFileUpload/upload, along with the chunk number, total chunk count, a unique file identifier, and the original filename.
  3. application/controllers/LargeFileUpload.php saves each chunk to a chunks/ directory as it arrives.
  4. Once all chunks for a file are present, the controller reassembles them in order into uploads/, then deletes the temporary chunk files.

Requirements

  • PHP 5.4+ (this is a CodeIgniter 3 application)
  • A webserver that can run PHP (Apache, Nginx + PHP-FPM, or php -S)

Running locally

  1. Serve the project root with a PHP-enabled webserver, e.g.:
    php -S localhost:8000
    
  2. Update $config['base_url'] in application/config/config.php to match the URL you're serving from (it currently points at http://localhost/frameworks/codeIgniter/).
  3. Visit the site root (or /large_file_upload) — both route to the upload form.
  4. Choose a file and click Start Upload. Uploaded files land in uploads/.

Project structure

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.

Note

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.

About

Upload large file in codeigniter3

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages