Welcome Guest, Not a member yet? Register   Sign In
[ask] error while uploading image data
#1

[eluser]Unknown[/eluser]
i have a news application. and i have a form to fill the news content. it has 3 forms, for title, image and news content. and 2 buttons, submit and reset.
when i had filled it all and send it to the database with clicking the submit button, the name of the image didnt recorded to the database, but the other input are successfully copied to the database and the image also successfully copied to the server.
what's wrong with my code ???
this is my code...

the controller...
Code:
function news_insert()
{
   $field_name = "gambar";
   $config['upload_path'] = './upload/';
   $config['allowed_types'] = 'gif|jpg|png';
   $config['max_size']    = '1000000';
   $config['max_width']  = '1024';
   $config['max_height']  = '768';
            
   $this->load->library('upload', $config);
            
   if ( ! $this->upload->do_upload($field_name))
   {
      redirect('mobil/news_admin');
   }    
   else
   {
       $data = array('upload_data' => $this->upload->data());

       $this->db->insert('news', $_POST);
                
       redirect('mobil/news', $data);
   }
}

the view...
Code:
<?php echo form_open_multipart('mobil/news_insert'); ?>
<?php echo br(1); ?>
<?php echo form_hidden('hit', '0') ?>
    
<!--tabel untuk menampilkan form news admin-->
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" width="35%" class="namagb">title :</td>
    <td valign="bottom">
        &lt;input name="judul" type="text" id="judul"&gt;
        &lt;?php echo br(2); ?&gt;
    </td>
  </tr>
  <tr>
    <td valign="top" class="namagb">picture :</td>
    <td valign="bottom">
        &lt;input type="file" name="gambar" id="gambar" /&gt;
        &lt;?php echo br(2); ?&gt;
    </td>
  </tr>
  <tr>
    <td valign="top" class="namagb">isi :</td>
    <td valign="bottom">
         &lt;textarea name="isi" cols="37" rows="10" id="isi"&gt;&lt;/textarea&gt;
     </td>
  </tr>
  <tr>
    <td>&lt;?php echo nbs(1); ?&gt;</td>
    <td>
       &lt;?php echo br(1); ?&gt;
       &lt;input type="submit" id="submit" value="save" /&gt;
       &lt;input type="reset" id="reset" value="cancel" /&gt;
    </td>
  </tr>
</table>
&lt;!--akhir tabel untuk menampilkan form news admin--&gt;
&lt;/form&gt;

ps : sorry my English is bad and mix with indonesian language Big Grin

thanks b4
#2

[eluser]Unknown[/eluser]
case closed !!!
i've found the answer :cheese:




Theme © iAndrew 2016 - Forum software by © MyBB