[eluser]Unknown[/eluser]
I'm really new to CI,
and I try to build a page where I can upload information of product with its image.
Here is my view :
Code:
<html>
<head>
<title>Soft Eng</title>
</head>
<body>
<?php echo form_open_multipart('welcome/masuk'); ?>
<table>
<tr>
<td><?php echo form_label('Product Name', $prod_name); ?></td>
<td><input type="text" name="prod_name" value="<?php echo set_value('prod_name'); >"size="50" /></td>
</tr>
<tr>
<td><?php echo form_label('Price', $price); ?></td>
<td><input type="text" name="price" value="<?php echo set_value('price'); ?>" size="11" /></td>
</tr>
<tr>
<td>File :</td>
<td><input type="file" name="image" value="<?php echo set_value('image'); ?>"></td>
</tr>
</table>
<?php echo form_submit('contact', 'Post'); ?>
<?php echo form_close(); ?>
and here is the function in my controller :
Code:
function masuk ()
{
$info['Created'] = date('Y-m-d H:i:s');
$info['prod_name'] = $this->input->post('prod_name', true);
$info['price'] = $this->input->post('price');
$info['username'] = $this->tank_auth->get_username();
$info['category'] = $this->input->post('catchoice');
$file = $_FILES['image']['tmp_name'];
$info['gambar'] = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if ($this->db->insert($this->table_name, $info))
$this->load->view('contact', $info);
}
I have problem with the image upload,
I check about the file upload in CI user guide,
but I don't understand how to use it since I have other things to do in the same function (insert data for product information)
Thanks before,