Automatically Create Directory When Uploading with CodeIgniter

Automatically Create Directory When Uploading With CodeIgniter

CodeIgniter does not automatically create a directory when uploading a file to a non-existent directory.

There are some work around by handling it in controller when uploading the file, but the easiest way is to extend CI_Upload library.

Harrison Emmanuel ( came up with a library to extend CI_Upload.

Be sure to check his github gist.

How To Use

To use this library, you can create MY_Upload.php under your application/libraries folder and use the following code.


And it’s done. You can load this library exactly the same as CodeIgniter upload library.


For more information:

Leave a reply:

Your email address will not be published.