[eluser]ppwalks[/eluser]
are you using codeigniters upload class if so you pass the variable to the model like this, here is mine using "do_upload":
Model:
Code:
function add_product($file_name) {
$data = array(
'product_name' =>$_POST['product_name'],
'description' =>$_POST['product_description'],
'price' => $_POST['product_price'],
'discount_price' => $_POST['discount_price'],
'thumbnail'=> $file_name,
'image'=> $file_name
);
$this->db->insert('product', $data);
}
And here is the portion of my controller
Code:
if (!empty($_FILES['product_thumb']))
{
// Specify configuration for File 1
$config['upload_path'] = './shop_images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
// Initialize config for File 1
$this->upload->initialize($config);
// Upload file 1, product_thumb is the name of my input for upload
if ($this->upload->do_upload('product_thumb'))
{
$data = array(
'thumbnail' => $this->upload->data()
);
$file_name = $data['thumbnail']['file_name'];
}
else
{
echo $this->upload->display_errors();
}
then pass it through to the model like so:
Code:
$this->MProducts->add_product($file_name);