codeigniter image not moving to folder: Undefined variable $file_name

VIEW:

<form method='post' action="<?php echo base_url('Reg_form/save')?>" enctype="multipart/form-data" name="reg_form">
  <div class="form-row">
    <div class="form-group col-md-3">
      <label for="">First name</label>
      <input type="text" class="form-control" id="fname" placeholder="First Name" name='Fname' required="">
    </div>
<div class="form-group col-md-3">
  <label for="">Last name</label>
  <input type="text" class="form-control" id="lname" placeholder="Last Name" name='Lname' required="">
</div>

<div class="form-group col-md-3">
  <label for="">Age</label>
  <input type="number" class="form-control" id="age" placeholder="age" name='Age' >
</div>
<div class="form-group col-md-2">
  <label for="">Image</label>
  <input type="file" class="btn btn-success form-control" name="img">
  
</div> 
<div class="form-group col-md-1">
  <label for=""> Save</label>
  <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Save</button>
</div>  
  </div>
    
  </form>

CONTROLLER:

function save() {

    $this->Reg_model->save();
    redirect(base_url('Reg_form/index'), 'refresh');
}

MODEL:

public function save() {

        // load base_url
        $this->load->helper('url');
        // Check form submit or not
                    
            $data = array();
                            
                // Set preference
                $config['upload_path'] = './assets/images'; 
                $config['allowed_types'] = 'jpg|jpeg|png|gif';
                $config['max_size']    = '100'; // max_size in kb
                $config['file_name'] = $_FILES['img']['name'];
                    
                //Load upload library
                $this->load->library('upload',$config);         
                
                // File upload
                if($this->upload->do_upload('img')){
                    // Get data about the file
                    $uploadData = $this->upload->data();
                    
                    $file_name = $uploadData['file_name'];
                    $data['response'] = 'successfully uploaded '.$filename;
                }else{
                    $data['response'] = 'failed';
                }
            
            $data = array(
            'Name' => $this->input->post('Fname'),
            'Fname' => $this->input->post('Lname'),
            'age' => $this->input->post('Age'),
            'image' => $file_name
        );

        $this->db->insert('student',$data);
        
        }

When I tried to upload the image it says undefined variable $file_name.

enter image description here this is the image of codeigniter showing the error

I am having a problem uploading an image file to a destination folder in my CodeIgniter application and it is not working at all. I have referred so many articles and downloaded some working one but they wouldn’t work once in my application