title: Uploading a file with CodeIgniter
body: <p>I want to upload an image with CodeIgniter. I followed the tutorial in the documentation, but it's not working. Does anyone know the solution? </p>
  
  <p>How do I have to send the image to the database?</p>
  
  <p><strong>View in Views/mod/mod.php</strong></p>
  
  <pre><code>&lt;form action="" method="post"&gt;
      &lt;?php if(isset($error)): ?&gt;
          &lt;?php echo $error ?&gt;
      &lt;?php endif; ?&gt;
  
      &lt;?php echo form_open_multipart('upload/do_upload');?&gt;
  
      &lt;label for="image"&gt;Afbeelding&lt;/label&gt;
      &lt;input type="file" id="image" name="image" /&gt;
  
      &lt;input type="submit" value="upload" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Upload succes in Views/mod/upload_succes.php</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Upload succes&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h3&gt;Your file was successfully uploaded!&lt;/h3&gt;
  
  &lt;ul&gt;
      &lt;?php foreach ($upload_data as $item =&gt; $value):?&gt;
          &lt;li&gt;&lt;?php echo $item;?&gt;: &lt;?php echo $value;?&gt;&lt;/li&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  
  &lt;p&gt;&lt;?php echo anchor('upload', 'Upload Another File!'); ?&gt;&lt;/p&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Upload.php in controllers/upload.php</strong></p>
  
  <pre><code>&lt;?php
  
  class Upload extends CI_Controller {
  
      public function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;helper(array('form', 'url'));
      }
  
      public function index()
      {
          $this-&gt;load-&gt;view('mod/mod', array('error' =&gt; ' ' ));
      }
  
      public function do_upload()
      {
          $config['upload_path']          = './uploads/';
          $config['allowed_types']        = 'jpg|png';
          $config['max_size']             = 100;
          $config['max_width']            = 1024;
          $config['max_height']           = 768;
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if ( ! $this-&gt;upload-&gt;do_upload())
          {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
              $this-&gt;load-&gt;view('mod/mod', $error);
          }
          else
          {
              $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
  
              $this-&gt;load-&gt;view('mod/upload_success', $data);
          }
      }
  }
  ?&gt;
  </code></pre>