O'Reilly logo

CodeIgniter 2 Cookbook by Rob Foster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Uploading files with CodeIgniter

CodeIgniter comes with very good file uploading support, which can take a lot of the hassle out of writing upload functions.

Getting ready

There are some settings you should be aware of which you'll probably need to change for your environment. Firstly, ensure that you load the upload library using:

$this->load->library('upload'); 

The following is a table of settings that should be placed in the $config array in the controller you are using, such as the following Fileupload controller:

Setting

Default

Change to

Description

upload_path

None

None

It specifies the path to the folder where the uploaded file should go. Ensure that you have set the correct permissions to enable CodeIgniter to write to it.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required