Upload files with CodeIgniter and Plupload

Why choose Plupload?

  • It's not based on flash.
  • You can track progress.
  • You can upload multiple files simultaneously.
  • It supports chunking.
  • It supports drag and drop.
  • It's free and open source.

Installation

Download the library here.

Copy its contents to a folder in your site. Let's say js/libs/plupload.

And use this code in your CodeIgniter view:



<script type="text/javascript" src="<?php echo base_url(); ?>js/libs/plupload/plupload.full.js"></script>

Creating a simple file uploader

Creating the upload button

First of all, you 'll need an upload button.

General options

runtimes

This is a comma separated list of runtimes that you want to initialize the uploader instance with. It will try to initialize each runtime in order if one fails it will move on to the next one.

max_file_size

Maximum file size that the user can pick. This string can be in the following formats 100b, 10kb, 10mb.

chunk_size

Enables you to chunk the file into smaller pieces for example if your PHP backend has a max post size of 1MB you can chunk a 10MB file into 10 requests. To disable chunking, remove this config option from your setup.

unique_names

Generate unique filenames when uploading. This will generate unqiue filenames for the files so that they don't for example collide with existing ones on the server.

flash_swf_url

URL to where the SWF file is for the Flash runtime.

silverlight_xap_url

URL to where the XAP file is for the Silverlight runtime.

required_features

Comma separated list of features that each runtime must have for it to initialize. Example:

required_features: 'chunks'

 

Learning Resources

The official site.

 

Post A Comment

Anti-Spam Quiz: