title: Upload issue in Codeigniter with image and text/numbers
body: <p>First of all sorry for the long post with code, but i feel like i need to explain myself straight. The issue is, i'm trying to insert some data into a database and also the file name in the RESTAURANT_IMAGE column. Everything inserts perfectly fine but the image doesn't upload and the file name is not inserted into the database.</p>
  
  <p>EDIT: Edited the callback function to properly return True or False and now i do the insert in the main function if the callback returns true.
  Now i am able to upload the image successfully but still dont get the file name and extension to put into my database.</p>
  
  <pre><code>    function restaurant_add()
  {
      $this-&gt;load-&gt;helper(array('form', 'url'));
  
      $this-&gt;load-&gt;library('form_validation');
  
      $config = array(
                                          array(
                                           'field'   =&gt; 'RestaurantName',
                                           'label'   =&gt; 'Restaurant Name',
                                           'rules'   =&gt; 'required|callback_restaurant_check'
                                          ),
                                          array(
                                           'field'   =&gt; 'RestaurantAddress',
                                           'label'   =&gt; 'Address',
                                           'rules'   =&gt; 'required'
                                          ),
                                          array(
                                           'field'   =&gt; 'RestaurantReservations',
                                           'label'   =&gt; 'Reservations',
                                           'rules'   =&gt; 'max_length[1]|integer'
                                          ),
                                          array(
                                           'field'   =&gt; 'RestaurantWifi',
                                           'label'   =&gt; 'RestaurantWifi',
                                           'rules'   =&gt; 'max_length[1]|integer'
                                          ),
                                          array(
                                              'field'   =&gt; 'RestaurantDelivery',
                                              'label'   =&gt; 'Restaurant Delivery',
                                              'rules'   =&gt; 'max_length[1]|integer'
                                           ),
                                          array(
                                              'field'   =&gt; 'RestaurantMultibanco',
                                              'label'   =&gt; 'RestaurantMultibanco',
                                              'rules'   =&gt; 'max_length[1]|integer'
                                          ),
                                          array(
                                                  'field'   =&gt; 'RestaurantImage',
                                                  'label'   =&gt; 'RestaurantImage',
                                                  'rules'   =&gt; ''
                                                   )
                                          );
  
              $this-&gt;form_validation-&gt;set_rules($config);
  
              if ($this-&gt;form_validation-&gt;run() == FALSE)
              {
                  $this-&gt;load-&gt;view('sample_navbar_view');
                  $this-&gt;load-&gt;view('restaurant_add');
                  return FALSE;
              }
              else
              {
              $file_name = $this-&gt;do_upload();
                  $data = array(
       'RESTAURANT_NAME' =&gt; $this-&gt;input-&gt;post('RestaurantName'),
       'RESTAURANT_ADDRESS' =&gt; $this-&gt;input-&gt;  post('RestaurantAddress'),
       'RESTAURANT_RESERVATIONS'=&gt; $this-&gt;input-&gt;  post('RestaurantReservations'),
       'RESTAURANT_WIFI'=&gt; $this-&gt;input-&gt;  post('RestaurantWifi'),
       'RESTAURANT_DELIVERY'=&gt; $this-&gt;input-&gt;  post('RestaurantDelivery'),
       'RESTAURANT_MULTIBANCO'=&gt; $this-&gt;input-&gt;    post('RestaurantMultibanco'),
       'RESTAURANT_OUTDOOR_SEATING'=&gt; $this-&gt;input-&gt;   post('RestaurantOutdoorSeating'),
       'RESTAURANT_IMAGE'=&gt; $file_name
  );
          $this-&gt;load-&gt;model('restaurant_model');
         $this-&gt;restaurant_model-&gt;restaurant_add($data);
  
                  return TRUE;
              }
  }
  </code></pre>
  
  <p>Callback function to check if the restaurant name exists, if it does, it doesn't register it, if it doesn't sends the data into the model.</p>
  
  <pre><code>function restaurant_check($restaurantname){
      $this-&gt;load-&gt;model('restaurant_model');
      $result = $this-&gt;restaurant_model-&gt;check_restaurant_name($restaurantname);
  
      if($result &gt; 0) {
          return FALSE;
  }
      else    {
              return TRUE;
          }
   }
  </code></pre>
  
  <p>I used the upload file article present in the <a href="https://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html" rel="nofollow">Codeigniter Documentation</a>.</p>
  
  <p>View Code:</p>
  
  <pre><code>&lt;div class="container"&gt;
  &lt;div class="row"&gt;
  &lt;div class="col-md-4 col-md-offset-4"&gt;
  &lt;?php echo form_open_multipart('restaurant/restaurant_add');?&gt;
  &lt;form name="restaurant_add" method="post" action="&lt;?php echo site_url().'Restaurant/restaurant_add'; ?&gt;"&gt;
  &lt;h2&gt;Register your Restaurant&lt;/h2&gt;
  &lt;input class="form-control" type="text" class="user" name="RestaurantName"      placeholder="Restaurant Name"&gt;
  &lt;input class="form-control"type="text" class="pass" name="RestaurantAddress" placeholder="Restaurant Address"&gt;
  &lt;input class="form-control"type="number" class="numero" name="RestaurantReservations" placeholder="Restaurant Rerservations"&gt;
    &lt;input class="form-control"type="number" class="numero" name="RestaurantWifi" placeholder="Wi-Fi"&gt;
    &lt;input class="form-control"type="number" class="numero" name="RestaurantDelivery" placeholder="Home Deliveries"&gt;
    &lt;input class="form-control"type="number" class="numero" name="RestaurantMultibanco" placeholder="Have Multibanco?"&gt;
      &lt;input class="form-control"type="number" class="numero" name="RestaurantOutdoorSeating" placeholder="Esplanada"&gt;
    &lt;input class="form-control"type="file" class="image" name="RestaurantImage" placeholder="Upload a Picture"&gt;
  &lt;div class="container"&gt;
    &lt;?php echo validation_errors(); ?&gt;
  &lt;/div&gt;
  &lt;button class="btn btn-danger"type="submit"&gt;Registar&lt;/button&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>EDIT: Model Code:</p>
  
  <pre><code>     function restaurant_add($info)
  {
    $query =
                  "INSERT INTO RESTAURANTS
                  (RESTAURANT_NAME,RESTAURANT_ADDRESS,RESTAURANT_RESERVATIONS,
          RESTAURANT_WIFI,RESTAURANT_DELIVERY,RESTAURANT_MULTIBANCO,
          RESTAURANT_OUTDOOR_SEATING,RESTAURANT_IMAGE
          )
                  VALUES
                  (
          '".$info['RESTAURANT_NAME']."',
                      '".$info['RESTAURANT_ADDRESS']."',
          '".$info['RESTAURANT_RESERVATIONS']."',
          '".$info['RESTAURANT_WIFI']."',
          '".$info['RESTAURANT_DELIVERY']."',
          '".$info['RESTAURANT_MULTIBANCO']."',
          '".$info['RESTAURANT_OUTDOOR_SEATING']."',
          '".$info['RESTAURANT_IMAGE']."'
                  )
                  ";
              $result =   $this-&gt;db-&gt;query($query);
            return TRUE;
  
  }
  
  function check_restaurant_name($restaurantname)    {
      $this-&gt;db-&gt;trans_begin();
      $query = "SELECT RESTAURANT_NAME FROM RESTAURANTS WHERE RESTAURANT_NAME = '".$restaurantname."'";
  
      $result = $this-&gt;db-&gt;query($query);
      $rows = $result-&gt;num_rows();
      if ($this-&gt;db-&gt;trans_status() === FALSE)
      {
              $this-&gt;db-&gt;trans_rollback();
      }
      else
      {
              $this-&gt;db-&gt;trans_commit();
      }
  return $rows;
  }
  </code></pre>
  
  <p>do_upload() function:</p>
  
  <pre><code>    public function do_upload()
   {
               $config['upload_path']          = './assets/images/restaurantes';
               $config['allowed_types']        = 'gif|jpg|png';
               $config['max_size']             = 2000;
               $config['max_width']            = 1024;
               $config['max_height']           = 768;
  
               $this-&gt;load-&gt;library('upload', $config);
  
               if ( ! $this-&gt;upload-&gt;do_upload('userfile'))
               {
                               $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
                               $this-&gt;load-&gt;view('success_view', $error);
               }
               else
               {
                               $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
  
                               $this-&gt;load-&gt;view('upload_success', $data);
               }
               $upload_data = $this-&gt;upload-&gt;data();
              //Returns array of containing all of the data related to the file you uploaded.
                              $file_name =  $this-&gt;upload-&gt;file_name;
      return $file_name;
  }
  </code></pre>