I'm trying to make a function in CodeIgniter (PHP) so users can add images to my database but I'm getting an error when I try to upload an image..

I'm using phpMyAdmin

Database name: kadokado

Table name: products

Table row name where i want to put these images to: product\_foto

image folder: upload

My controller file (Product.php):

```
    class Product extends CI_Controller { 

    var $data = array();

       public function __construct()
 {
  parent::__construct();
 }

}

     public function index()
 {
  $config = array (
   'upload_path' => 'upload/',
   'allowed_types' => 'jpg|jpeg|png|bmp',
   'max_size' => 0,
   'filename' => url_title($this->input->post('file'))

   );
   $this->load->library('upload', $config);

   if ($this->upload->do_upload('file')) {
    $this->db->insert('products', array(
        'product_foto' => $this->upload->product_foto
     ));
     $this->session->set_flashdata('msg', 'Success');
   }

  $this->load->view('product_form', $this->data);
 }

```

}

This is my view file (product\_form.php) :

```
<?php
echo $this->session->flashdata('msg');
echo form_open_multipart();
echo form_upload('file');
echo form_submit('upload', 'Upload');
echo form_close();
?>

```

And these are the errors I'm getting:`

```
  A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Upload::$product_foto

Filename: controllers/Product.php

Line Number: 21

Backtrace:

File: /home/ubuntu/workspace/application/controllers/Product.php
Line: 21
Function: _error_handler

File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once

A Database Error Occurred

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO `products` (`product_foto`) VALUES (NULL)

Filename: controllers/Product.php

Line Number: 22

```