[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">
<input name="judul" type="text" id="judul">
<?php echo br(2); ?>
</td>
</tr>
<tr>
<td valign="top" class="namagb">picture :</td>
<td valign="bottom">
<input type="file" name="gambar" id="gambar" />
<?php echo br(2); ?>
</td>
</tr>
<tr>
<td valign="top" class="namagb">isi :</td>
<td valign="bottom">
<textarea name="isi" cols="37" rows="10" id="isi"></textarea>
</td>
</tr>
<tr>
<td><?php echo nbs(1); ?></td>
<td>
<?php echo br(1); ?>
<input type="submit" id="submit" value="save" />
<input type="reset" id="reset" value="cancel" />
</td>
</tr>
</table>
<!--akhir tabel untuk menampilkan form news admin-->
</form>
ps : sorry my English is bad and mix with indonesian language
thanks b4