title: codeigniter success insert to database but failed to insert uploaded file
body: <p>I'm new here, so nice to meet you all.</p>
  
  <p>I have trouble with codeigniter.</p>
  
  <p>Maybe hard to tell so I will show all of my code :</p>
  
  <p>my controller :</p>
  
  <pre><code> function upload_barang(){
  
      $this-&gt;admin_model-&gt;login();
  
      $this-&gt;admin_model-&gt;valid_product();
  
      $config['upload_path'] = './produk/';
      $config['allowed_types'] = 'jpg';
      $config['max_size'] = '100';
      $config['max_width']  = '400';
      $config['max_height']  = '400';
  
      $this-&gt;load-&gt;library('upload',$config); 
  
      $data['query'] = $this-&gt;db-&gt;get('kategori');
  
       if($this-&gt;form_validation-&gt;run() == FALSE &amp;&amp; ! $this-&gt;upload-&gt;do_upload()) {
  
       $data['error'] = $this-&gt;upload-&gt;display_errors();
  
       $data['success'] = '';
  
       $this-&gt;load-&gt;view('backoffice/tambahbarang',$data);
  
       } else {
  
         $upload_data = $this-&gt;upload-&gt;data();
  
        $data['error'] = '';
  
        $data = array(
        'idkategori' =&gt; $this-&gt;input-&gt;post('idkategori'),
        'namabarang' =&gt; $this-&gt;input-&gt;post('nbarang'),
        'image' =&gt;  $upload_data['file_name'],
        'status' =&gt; 1
     );
  
      $data_insert = $this-&gt;db-&gt;insert('barang',$data);
  
      if($data_insert == TRUE) {
  
        $data['query'] = $this-&gt;db-&gt;get('kategori');
  
        $query = $this-&gt;db-&gt;get('barang');
  
        $rows = $query-&gt;row();
  
        $data['idbarang'] = $rows-&gt;idbarang; 
  
        $harga = array(
        'idbarang' =&gt; $data['idbarang'],
        'satuan' =&gt; $this-&gt;input-&gt;post('stcbarang'),
        'harga' =&gt; $this-&gt;input-&gt;post('hbarang')
     );
  
     $this-&gt;db-&gt;insert('hargabarang',$harga);
  
     $data['success'] = '&lt;b&gt;Barang Telah Ditambahkan&lt;/b&gt;';
  
      $this-&gt;load-&gt;view('backoffice/tambahbarang',$data);  
  
     } else {
  
      $data['success'] = '&lt;b&gt;Barang Gagal Ditambahkan&lt;/b&gt;';
  
      $this-&gt;load-&gt;view('backoffice/tambahbarang',$data);  
  
      }
  
    }  
  } 
  </code></pre>
  
  <p>This code success insert all of data to database, except on column 'image' that I fill with '$upload_data['file_name']' this empty on my database.</p>
  
  <p>what's wrong with my code?</p>
  
  <p>please help thanks</p>